frostming / marko

A markdown parser with high extensibility.
https://marko-py.readthedocs.io/
MIT License
357 stars 38 forks source link

multiline footnotes incorrectly parsed #178

Closed nschloe closed 11 months ago

nschloe commented 11 months ago

MWE:

import marko
from marko.md_renderer import MarkdownRenderer
from marko.ext.gfm import gfm

text = r"""
[^lorem]

[^lorem]: Ipsum
    dolor sit amet.
"""

doc = gfm.parse(text)

for c in doc.children:
    print(c)

Output:

<marko.block.BlankLine object at 0x7fd89ae2d950>
<marko.ext.gfm.elements.Paragraph object at 0x7fd89ae18110>
<marko.block.BlankLine object at 0x7fd89ae184d0>
<marko.block.LinkRefDef object at 0x7fd89aff6e50>
<marko.block.CodeBlock object at 0x7fd89ae2dc50>

(The last item shouldn't be a CodeBlock.)

frostming commented 11 months ago

Footnote is an opt-in and not included by gfm by default. There are several ways to enable it:

from marko.ext.gfm import gfm
gfm.use("footnote")
# or
gfm = marko.Markdown(extensions=["gfm", "footnote"])