frostming / marko

A markdown parser with high extensibility.

Home Page:https://marko-py.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

multiline footnotes incorrectly parsed

nschloe opened this issue · comments

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.)

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"])