lepture / mistune

A fast yet powerful Python Markdown parser with renderers and plugins.
http://mistune.lepture.com/
BSD 3-Clause "New" or "Revised" License
2.59k stars 251 forks source link

Inline math incorrectly removes newlines #371

Open nschloe opened 11 months ago

nschloe commented 11 months ago

MWE:

import mistune
from rich import print

markdown = mistune.create_markdown(
    renderer="ast",
    plugins=["math"],
)

tokens = markdown("$`a+%\nb`$")

print(tokens)

Output:

[
    {
        'type': 'paragraph',
        'children': [
            {'type': 'text', 'raw': '$'},
            {'type': 'codespan', 'raw': 'a+% b'},
            {'type': 'text', 'raw': '$'}
        ]
    }
]