## Disallowing inline content in <li>

Post here questions and problems related to editing and publishing DITA content.
chrispitude
Posts: 427
Joined: Thu May 02, 2019 2:32 pm

### Disallowing inline content in <li>

In DITA, the <li> element allows both block and inline content:

Code: Select all

<ol>
<li>Do this step first.
<li>
<p>Do this step second:</p>
<fig><image href="second_step.png"/></fig>
</li>
</ol>
I would like to disallow inline content in <li> elements, and allow only block elements. In cc_config_ext.xml, I can reject inline elements as follows:

Code: Select all

<elementProposals path="li" rejectElements="sup sub codeph [and so on]"/>
but I can't seem to find the right keyword that rejects plaintext itself. I tried text(), \text, and \\text, but none of these prevent plaintext from being typed in an <li> element.

Is there a magic rejectElements keyword that applies to non-whitespace plaintext, or is this list for elements only?

Thanks!
Posts: 41
Joined: Wed Jun 22, 2016 2:48 pm

### Re: Disallowing inline content in <li>

Hi Chris,

Unfotunatelly, the magic method doesn't exist...yet
I've added an internal issue to allow this behaviour.

The second best thing you could do is to create a schematron that signals when text is inserted in that list item.
Also, a quick fix that proposes wrapping the plain text in an element would also be usefull.

Regards,
<oXygen/> XML Editor
http://www.oxygenxml.com
chrispitude
Posts: 427
Joined: Thu May 02, 2019 2:32 pm

### Re: Disallowing inline content in <li>

That's similar to what we're doing right now, a Schematron check to catch the issue, and a refactoring operation to wrap inline content in <li> in <p>. (I used refactoring because sometimes there is a mix of inline and block content in an <li>, and I wanted to handle it robustly.)

The strange thing is, our cc_config_ext.xml is configured to auto-insert a <p> in new <li> elements, and yet this still happens. I guess it won't be foolproof until I update the schema to do it the right way.
Posts: 41
Joined: Wed Jun 22, 2016 2:48 pm

### Re: Disallowing inline content in <li>

Hi Chris,

This
cc_config_ext.xml is configured to auto-insert a <p> in new <li> elements, and yet this still happens
This is what I've tested: added the

Code: Select all

<elementProposals path="li" insertElements="p"/>
in the cc_config xml.
Every time I inseted a li from Content Completion, the paragraph was also added.
Indeed, if the insert list item toolbar action was used, the list item is inserted without the p. For this to also work, the listitem Author action should also be modified.
Regards,
<oXygen/> XML Editor
http://www.oxygenxml.com
chrispitude
Posts: 427
Joined: Thu May 02, 2019 2:32 pm

### Re: Disallowing inline content in <li>

adrian_sorop wrote: Tue Jan 18, 2022 9:29 pmIndeed, if the insert list item toolbar action was used, the list item is inserted without the p. For this to also work, the listitem Author action should also be modified.
Ah ha! I bet this is how the inline text is sneaking into <li> elements.

Adrian, can I ask you to file an enhancement for elements inserted though such actions to consider the <elementProposals> settings? Otherwise, it's going to become very complex (and not worth the trouble) to edit framework actions every time simple changes are made to the cc_config_ext.xml file.

This also ensures that the user experience is consistent, regardless of how the element is inserted.

Thanks!
Posts: 41
Joined: Wed Jun 22, 2016 2:48 pm

### Re: Disallowing inline content in <li>

I've logged the feature request with internal id EXM-49754.
I'll update this thread once the issue is fixed.

Thanks,
<oXygen/> XML Editor
http://www.oxygenxml.com
chrispitude
Posts: 427
Joined: Thu May 02, 2019 2:32 pm

### Re: Disallowing inline content in <li>

Hi Chris,

Unfortunately, the magic method doesn't exist...yet
I've added an internal issue to allow this behaviour.

Can you let me know the issue ID of supporting text() (or something equivalent) in rejectElements specifications?

Thanks!

- Chris
Posts: 41
Joined: Wed Jun 22, 2016 2:48 pm

### Re: Disallowing inline content in <li>

Hi Chris,
My bad, I forgot to mention it.
Here it is

EXM-49670 - As a user, I want to restrict element content type from mixed to element only through "cc_config.xml", so that my user don't write content in an element

Have a nice day,