trentm / python-markdown2

markdown2: A fast and complete implementation of Markdown in Python
Other
2.64k stars 431 forks source link

Mixed ordered and unordered lists rendering as per spec? #478

Closed Braintelligence closed 1 year ago

Braintelligence commented 1 year ago

Hello everyone!

When using ordered and unordered lists together strange behaviour is being observed. Strange in the sense that markdown parsers seem to interpret it differently.

I'm using easyMDE as a markdown editor and python-markdown2 for actual rendering.

But easyMDE interprets mixed lists differently than python-markdown2. See below.

To Reproduce and Screenshots Use the following example content:

1. Test: 
Lorem Ipsum
- Lorem Ipsum
- Lorem Ipsum
- Lorem Ipsum

easyMDE Preview: image

<ol>
<li>Test: 
Lorem Ipsum</li>
</ol>
<ul>
<li>Lorem Ipsum</li>
<li>Lorem Ipsum</li>
<li>Lorem Ipsum</li>
</ul>

python-markdown2 rendering (via django-markdown2): image

<ol>
<li>Test:<br>
Lorem Ipsum</li>
<li>Lorem Ipsum</li>
<li>Lorem Ipsum</li>
<li>Lorem Ipsum</li>
</ol>

Expected behavior Not sure who is in the wrong here, but I'd expect it to render the same in the easyMDE preview and python-markdown2. If possible I'd want for easyMDE to preview the same behaviour that python-markdown2 is depicting.

If python-markdown2 is acting correctly I'd be happy if you could provide me to the specification which easyMDE is implementing the wrong way here.

Thanks a lot!

Crozzers commented 1 year ago

My gut instinct is to say that python-markdown2 is behaving correctly here since it is accurately representing what you have put, which is a line break after your point.

This behaviour is not really clarified in the original daringfireball markdown spec, however, babelmark seems to indicate that most implementations seem to lean towards the easyMDE way of doing it. Commonmark also produces the easyMDE result.

Perhaps for the sake of conformance, python-markdown2 should also do this

Braintelligence commented 1 year ago

Thank you very much for your insight :). In that case I hope that python-markdown2 will conform to this behaviour in the foreseeable future; that would be awesome.

Crozzers commented 1 year ago

Hang on a sec, I just tried this on the master branch d6651a4 and it produced the same output that easyMDE produced. Are you using any markdown extras? Perhaps django is messing with the input?

EDIT: no it does not. I was just looking for the <br> and forgot to check the rest of the HTML. This is what it outputted:

<ol>
<li>Test: 
Lorem Ipsum</li>
<li>Lorem Ipsum</li>
<li>Lorem Ipsum</li>
<li>Lorem Ipsum</li>
</ol>
Braintelligence commented 1 year ago

Just for the sake of completeness, I am indeed using some extras. These are: safe, code-friendly, break-on-newline, strike, tables

Thanks for checking!

Crozzers commented 1 year ago

Ok so the break-on-newline is the one that inserts the <br> tag.

And upon further reading, I completely mis-read the code snippet for the python-markdown2 output. I focused on the <br> tag and completely missed how wrong that output is, so I apologise for that and I'm looking into it

Braintelligence commented 1 year ago

Hello everyone,

where can I find information about when the next release is to be expected so I can incorporate this fix into my project? :)

Thanks a lot!

nicholasserra commented 1 year ago

We don't have a set release schedule. I'll prioritize this one though. Once a few more fixes land i'll cut one and let you know.

nicholasserra commented 1 year ago

@Braintelligence 2.4.6 has been released