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

Bullet and Numbering Levels Don't Function #1206

Closed JonathanLindsey closed 2 years ago

JonathanLindsey commented 2 years ago

Input file:

# Test

- hi
  - hello
  - there

* hi
  * hello
  * there

1. hi
   1. hello
   2. there
2. hi
   1. hello
   2. there

Code:

import markdown

markdown.markdownFromFile(input='input.md', output='output.html', extensions=['sane_lists'])

Output HTML:

<h1>Test</h1>
<ul>
<li>hi</li>
<li>hello</li>
<li>
<p>there</p>
</li>
<li>
<p>hi</p>
</li>
<li>hello</li>
<li>there</li>
</ul>
<ol>
<li>hi</li>
<li>hello</li>
<li>there</li>
<li>hi</li>
<li>hello</li>
<li>there</li>
</ol>

Rendered:

image

I had hoped it would render more like VSCode does it:

image

JonathanLindsey commented 2 years ago

I edited my original post and title when I realized I needed the sane_lists extension. That helped (screenshots show the latest). Am I needing to use another extension? I tried using all the extensions listed here. None of the third party extensions are standing out to me.

JonathanLindsey commented 2 years ago

I just had to add tab_length=2 as documented here under "Indentation/Tab Length".

import markdown

markdown.markdownFromFile(input='input.md', output='output.html', extensions=['sane_lists'], tab_length=2)