lepture / mistune

A fast yet powerful Python Markdown parser with renderers and plugins.

Home Page:http://mistune.lepture.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inline math incorrectly removes newlines

nschloe opened this issue · comments

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': '$'}
        ]
    }
]