Page 1 of 1

Force p-tag in new <li> elements

Posted: Fri Nov 13, 2015 1:34 am
by rdelong
I'd like to have the editor automatically add a <p> tag inside the <li> elements of my unordered lists <ol>. Is this possible in Oxygen without manipulating the DTD?
For example,

Code: Select all

<ul>
<li><p/></li>
...
</ul>
Currently, adding a new <li> tags omit the <p> tag.

Thanks for the input.

Re: Force p-tag in new <li> elements

Posted: Fri Nov 13, 2015 1:07 pm
by mihaela
Hi,

What you can do is to update the action that is used to insert list items, to change the fragment that is inserted in the document (from <li/> to <li><p/></li>).

For example, for DITA document type (this is similar for other built-in frameworks) you have to go to "Options"->"Preferences"->"Document Type" option page, select the DITA document type and press "Edit". All the actions are defined in "Author" tab, "Actions" subtab.
To update the list item action follow these steps:
  • Select the list item action from the actions list (it has the "listitem" ID) and press "Edit". The "Action" dialog is opened.
  • In the "Operations" section you will see that there are multiple operations defined, each of them being activated in a specific context (see the XPath expresion that must be evaluated to determine when the operation is applied). You have to search for all the operations that are executed in the context of ol or ul and change the corresponding fragment argument from

    Code: Select all

    <li/>
    to

    Code: Select all

     <li><p/></li>
    .
The "listitem" action is added by default in the Toolbar, but you can add it also in the content completion list.
To do that, go back to document type edit dialog, "Author" tab, "Content Completion" subtab, select the action from the "Available actions" section and add it to the "Current actions" section.

Please let me know if you need further information.

Re: Force p-tag in new <li> elements

Posted: Fri Nov 13, 2015 10:00 pm
by rdelong
Cool. This works well.

However, the context menu for inserting a new <li> element still contains <li/> code without the <p/> code.

Where do I edit the context menu items?

Re: Force p-tag in new <li> elements

Posted: Mon Nov 16, 2015 10:20 am
by mihaela
Hi,

In the "Author" tab, "Content Completion" subtab there is also a "Filter" section where you can specify the name of the content completion items that you want to be filtered from the "Content Completion Window", "Elements View", "Element Insert Menus"and "Entitties View".

Unfortunately, there is a limitation that I think you will encounter: the "New li" entry from the content completion cannot be filtered individually.
The "New li" item appears when you want to split the li element at caret. So, it is a split operation that can be filtered by specifying "<Split>" as item name in the "Remove item" dialog (that appears when you try to add an entry in the "Filter" section from "Content Completion" tab). If you do that, all the split items will be filtered from the content completion (e.g. "New p").

We plan to remove that limitation and also to implement an easier way to specify the content to be added when an element is inserted in the document.
We will let you know when these improvements will be available.

Re: Force p-tag in new <li> elements

Posted: Wed May 04, 2016 3:56 pm
by Radu
Hi,

To bring completion to this older forum thread, in Oxygen 18.0 there is a content completion configuration XML document which can be used to state that certain elements should have required child sub elements or attributes:

https://www.oxygenxml.com/doc/versions/ ... ually.html

Regards,
Radu