Force p-tag in new <li> elements

Questions about XML that are not covered by the other forums should go here.
rdelong
Posts: 68

Force p-tag in new <li> elements

Fri Nov 13, 2015 1:34 am

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.
mihaela
Posts: 190

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

Fri Nov 13, 2015 1:07 pm

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.
Mihaela Calotescu
http://www.oxygenxml.com
rdelong
Posts: 68

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

Fri Nov 13, 2015 10:00 pm

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?
mihaela
Posts: 190

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

Mon Nov 16, 2015 10:20 am

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.
Mihaela Calotescu
http://www.oxygenxml.com
Radu
Posts: 5866

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

Wed May 04, 2016 3:56 pm

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/18.0/ug-editor/topics/configure-elements-attr-cc-individually.html

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Return to “General XML Questions”

Who is online

Users browsing this forum: No registered users and 0 guests