You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feature request(list): prevent extra p tags inside list items #8
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
The text inside list items is already wrapped in a li tag. Additional p inside list elements isn’t needed.
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:
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 for opening this issue and sorry i didn't get around to really looking at it until now. While your PR was successful in pressuring me to give this attention, I think the first step is to agree on what the correct behavior is before getting too deep into discussing the proposed changes.
I don't think that the first and third examples in your MCVE are bugs because the blank lines alone would have been sufficient to cause those <p> tags without any comments. For example:
1. Kira first
1. Kira second
1. Kira third
produces the same "bad" output with or without this extension. Blank lines matter in markdown and IMO this extension shouldn't be in the business of hiding them from the markdown parser.
Regarding the second example in your MCVE in which there are no blank lines, note that the extra newline is still what is causing the undesirable behavior here. For example, you get the desired behavior with no newline:
1. Kira first <!--- Kira comment -->
1. Kira second
1. Kira third
However, I am more sympathetic towards addressing your second example because the comment line alone is causing the undesirable behavior and it it is nice and normal to be able to have comments on their own line.
So my current thinking is that it would be a nice improvement if, when a line consists of nothing but a comment and possibly whitespace before and/or after that comment, the entire line is deleted prior to markdown processing. This would prevent lines consisting solely of comments from inducing markdown to create <p> tags around adjacent items.
Activity
Fix ryneeverett#8
ryneeverett commentedon Feb 16, 2025
Thanks for opening this issue and sorry i didn't get around to really looking at it until now. While your PR was successful in pressuring me to give this attention, I think the first step is to agree on what the correct behavior is before getting too deep into discussing the proposed changes.
I don't think that the first and third examples in your MCVE are bugs because the blank lines alone would have been sufficient to cause those
<p>tags without any comments. For example:produces the same "bad" output with or without this extension. Blank lines matter in markdown and IMO this extension shouldn't be in the business of hiding them from the markdown parser.
Regarding the second example in your MCVE in which there are no blank lines, note that the extra newline is still what is causing the undesirable behavior here. For example, you get the desired behavior with no newline:
However, I am more sympathetic towards addressing your second example because the comment line alone is causing the undesirable behavior and it it is nice and normal to be able to have comments on their own line.
So my current thinking is that it would be a nice improvement if, when a line consists of nothing but a comment and possibly whitespace before and/or after that comment, the entire line is deleted prior to markdown processing. This would prevent lines consisting solely of comments from inducing markdown to create
<p>tags around adjacent items.What do you think?