miyuchina / mistletoe

A fast, extensible and spec-compliant Markdown parser in pure Python.
MIT License
841 stars 119 forks source link

feat(markdown-renderer): option to normalize spacing after the list marker #202

Closed pbodnar closed 11 months ago

pbodnar commented 11 months ago

This follows #197 and adds the possibility to switch ON the original renderer behavior when the space after list marker (called leader in mistletoe) collapsed just to 1 space.

coveralls commented 11 months ago

Coverage Status

coverage: 94.153% (+0.003%) from 94.15% when pulling b518edf17eb17bce4c496affe068afe193190ac7 on feature/option-to-normalize-space-after-list-leader into 13d1c1116b33adc6d9373a7302099fd49a0236a4 on master.

pbodnar commented 11 months ago

@allets, @anderskaplan, this PR follows the discussions from #197, provided you would like to give feedback. If no one protests in a few days, I would merge this to the master. :)

anderskaplan commented 11 months ago

lgtm! just one thought about the naming of the flag, which is now very specfic. I believe that there are basically two modes you might want to run the Markdown renderer in: either you want it to stay as faithful to the original as possible, or you want the generated Markdown to be as regular (normalized) as possible. I can imagine that other options like this one will come, and maybe it's better to bundle them together with a single "normalize whitespace" option.

pbodnar commented 11 months ago

@anderskaplan, thanks for your feedback. So I would rename the flag to normalize_whitespace, with an outlook that we can gradually take this flag into account in more places of the renderer, right? I haven't studied the renderer thoroughly... :P

anderskaplan commented 11 months ago

@anderskaplan, thanks for your feedback. So I would rename the flag to normalize_whitespace, with an outlook that we can gradually take this flag into account in more places of the renderer, right? I haven't studied the renderer thoroughly... :P

yes exactly!

pbodnar commented 11 months ago

yes exactly!

OK, so I've generalized the newly introduced option. Hopefully fine now? :)

allets commented 11 months ago

@pbodnar, good! Thanks for your commit that fixed my omission. I like the idea of the generalization. It works fine.