Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to keep a lonely <p> element in a <li> tag #16602

Open
gdevreese opened this issue Jun 19, 2024 · 2 comments
Open

How to keep a lonely <p> element in a <li> tag #16602

gdevreese opened this issue Jun 19, 2024 · 2 comments
Labels
type:question This issue asks a question (how to...).

Comments

@gdevreese
Copy link

📝 How to keep a lonely <p> element in a <li> tag

Hello everyone,

What I'm trying to achieve is to keep my paragraph tags inside a list item.
If I add this markup into the HTML source mode, the <p> will automatically disappear when switching back & forth to this mode

Input

<ul>
    <li>
        <p>
            test 1
        </p>
    </li>
</ul>

after switching back & forth HTML source mode, output:

<ul>
    <li>
            test 1
    </li>
</ul>

What confuses me more is that when using two <p> inside the editor, the behavior is different:

input :

<ul>
    <li>
        <p>
            test 1
        </p>
        <p>
            test 2
        </p>
    </li>
</ul>

output :

<ul>
    <li>
        <p>
            test 1
        </p>
        <p>
            test 2
        </p>
    </li>
</ul>

I am using default Drupal implementation but I was also able to reproduce on the feature-rich editor.
I can't find any configuration setting for this particular setup, nor any issue related.. Am I missing something, or is there anything I can do to prevent this behavior ?

Thanks in advance,

@gdevreese gdevreese added the type:question This issue asks a question (how to...). label Jun 19, 2024
@Reinmar
Copy link
Member

Reinmar commented Jun 24, 2024

There's no configuration option for this behavior and I'd say it's hard to override this behavior without it.

May I ask why you need the paragraph within a single-block <li>?

The problem is: In huge number of cases it superfluous and most editors won't output them, that's why we're not doing this too.

@Witoso Witoso added the pending:feedback This issue is blocked by necessary feedback. label Jul 1, 2024
@daoutis
Copy link

daoutis commented Jul 8, 2024

Why is it even removed in the first place? Having a P tag inside a LI tag is not considered invalid HTML, so I think it should be kept if people insert it.

@CKEditorBot CKEditorBot removed the pending:feedback This issue is blocked by necessary feedback. label Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:question This issue asks a question (how to...).
Projects
None yet
Development

No branches or pull requests

5 participants