Python-Markdown / markdown

A Python implementation of John Gruber’s Markdown with Extension support.
https://python-markdown.github.io/
BSD 3-Clause "New" or "Revised" License
3.74k stars 858 forks source link

list render #1316

Closed redstoneleo closed 1 year ago

redstoneleo commented 1 year ago

The following would not be rendered as a lsit

**[Usage](http://127.0.0.1:8000/cms/pages/82/edit/)**:
- First item
- Second item
- Third item
- Fourth item

However, if you add a new line below the first line, that is,

**[Usage](http://127.0.0.1:8000/cms/pages/82/edit/)**:

- First item
- Second item
- Third item
- Fourth item

it works.

Any way to make the first one work?I know editors like stackedit and dillinger accept it.

Code to test:

import markdown
s1='''**[Usage](http://127.0.0.1:8000/cms/pages/82/edit/)**:
- First item
- Second item
- Third item
- Fourth item'''

s2='''**[Usage](http://127.0.0.1:8000/cms/pages/82/edit/)**:

- First item
- Second item
- Third item
- Fourth item'''

html = markdown.markdown(s1)
print(html)
waylan commented 1 year ago

Our current behavior matches the reference implementation (markdown.pl). I see that CommonMark matches the requested behavior. However, we are not a CommonMark implementation and have no interest in becoming one (we are an old-school pure Markdown implementation and proud of it). Therefore, we will not be making the requested change.

As an aside, a Markdown linter will suggest that the blank line be added to ensure a well formed document. That makes it easy to read and ensures all implementations will interpret it the same. Therefore, I recommend that everyone always ensure their Markdown it well formed. In other words, I would suggest adding the blank line regardless of whether the parser requires it or not.