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.79k stars 863 forks source link

Bug: Sublists are not rendered correctly #1229

Closed Heiko-san closed 2 years ago

Heiko-san commented 2 years ago

Imagine the following list:

* a
  * b
  * c
* d

Which markdown renders as:

However the markdown python module seems to render it as a flat list:

This is no matter if I use the plugin sane_lists or not ...

#!/usr/bin/env python
import markdown as md

markdown = """
# list

* a
  * b
  * c
* d

"""

_MD_EXTENTIONS = [
    'tables',
    #'sane_lists',
]
html = md.markdown(markdown, extensions=_MD_EXTENTIONS)
print(html)
<h1>list</h1>
<ul>
<li>a</li>
<li>b</li>
<li>c</li>
<li>d</li>
</ul>

I'm using Ubtunu 20.04

python --version
Python 3.8.10
pip freeze
importlib-metadata==4.11.2
Markdown==3.3.6
pkg_resources==0.0.0
zipp==3.7.0
facelessuser commented 2 years ago

You need to indent sublists four space.

Heiko-san commented 2 years ago

Ok, thanks, that helped. :)

I'd still consider this a bug, however. The "solution" seems more like a workaround to me.

facelessuser commented 2 years ago

As far as Python Markdown is concerned, this is not a bug. I'll link you to the maintainer's official response: https://github.com/Python-Markdown/markdown/issues/1204#issuecomment-992499686.

Keep in mind that Python Markdown is an old-school parser, and is not a CommonMark parser. This behavior is unlikely to change.

Heiko-san commented 2 years ago

I see. Thanks again. :) Well I think I can live with that solution. ;)