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

feature request(list): prevent extra p tags inside list items #8

Open
Kristinita opened this issue Jan 12, 2024 · 0 comments
Open

feature request(list): prevent extra p tags inside list items #8

Kristinita opened this issue Jan 12, 2024 · 0 comments

Comments

@Kristinita
Copy link

Kristinita commented Jan 12, 2024

1. Summary

It would be nice if python-markdown-comments would prevent adding extra <p></p> tags inside <li></li> if the user adds comments between list items.

2. MCVE

2.1. KiraListWithComments.md

1. Kira first

<!--- Kira comment -->

1. Kira second
1. Kira third

or

1. Kira first
<!--- Kira comment -->
1. Kira second
1. Kira third

or

1. Kira first

<!--- Kira 
multiline
comment -->

1. Kira second
1. Kira third

2.2. Command

python -m markdown -x mkdcomments KiraListWithComments.md

2.3. Behavior

2.3.1. Current
<ol>
<li>
<p>Kira first</p>
</li>
<li>
<p>Kira second</p>
</li>
<li>Kira third</li>
</ol>

2 extra p tags.

This behavior is as if the file KiraListWithComments.md would have an empty line between the first and second item of the list.

1. Kira first

1. Kira second
1. Kira third
2.3.2. Desired
<ol>
<li>Kira first</li>
<li>Kira second</li>
<li>Kira third</li>
</ol>

No p tags.

This behavior is as if the file KiraListWithComments.md wouldn’t have empty lines between the items of the list.

1. Kira first
1. Kira second
1. Kira third

3. Reasons why the feature is needed

  1. The text inside list items is already wrapped in a li tag. Additional p inside list elements isn’t needed.

  2. List items with p and without it has different interline spacing. See an example of a real list, where items 1, 2 and 3 hasn’t p tag, but items 4 and 5 has:

    p tag interline spacing

  3. Extra p tags increase a DOM size. A large DOM tree isn’t the best idea.

4. Not helped

I can’t find Python Markdown extension and any third-party tool at all, which could resolve this problem. I use HTML Tidy for fixing Python Markdown problems, but for the case described in my MCVE, it doesn’t remove extra p.

If you know of a third-party tool that can solve this problem without changes in python-markdown-comments, please tell me about it.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant