-
Notifications
You must be signed in to change notification settings - Fork 274
Closed
Description
Consider the following markdown:
Lorem ipsum.[^a][^b]
[^a]: Foo
[^b]: Bar
Which on GitHub, renders thus:
With pulldown-cmark v0.9.6, these were correctly parsed as two consecutive footnote references:
➜ cargo run -- --events --enable-footnotes < in.md
Compiling pulldown-cmark v0.9.6 (/home/zoni/Workspace/pulldown-cmark)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.61s
Running `/home/zoni/Workspace/pulldown-cmark/target/debug/pulldown-cmark --events --enable-footnotes`
0..21: Start(Paragraph)
0..12: Text(Borrowed("Lorem ipsum."))
12..16: FootnoteReference(Borrowed("a")) // <--- footnote ref a
16..20: FootnoteReference(Borrowed("b")) // <--- footnote ref b
0..21: End(Paragraph)
22..32: Start(FootnoteDefinition(Borrowed("a")))
28..31: Start(Paragraph)
28..31: Text(Borrowed("Foo"))
31..32: SoftBreak
28..31: End(Paragraph)
22..32: End(FootnoteDefinition(Borrowed("a")))
32..42: Start(FootnoteDefinition(Borrowed("b")))
38..42: Start(Paragraph)
38..41: Text(Borrowed("Bar"))
38..42: End(Paragraph)
32..42: End(FootnoteDefinition(Borrowed("b")))
EOF
With pulldown-cmark 0.11 (v0.11.0-44-g4e9bc2c), this fails to resolve both footnote references correctly. Notably, it fails on both the old:
➜ cargo run -- --events --enable-old-footnotes < in.md
Compiling pulldown-cmark v0.11.0 (/home/zoni/Workspace/pulldown-cmark/pulldown-cmark)
Compiling pulldown-cmark-escape v0.11.0 (/home/zoni/Workspace/pulldown-cmark/pulldown-cmark-escape)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.63s
Running `/home/zoni/Workspace/pulldown-cmark/target/debug/pulldown-cmark --events --enable-old-footnotes`
0..21: Start(Paragraph)
0..12: Text(Borrowed("Lorem ipsum."))
12..13: Text(Borrowed("[")) // <---- footnote ref a incorrectly parsed as text
13..15: Text(Borrowed("^a"))
15..16: Text(Borrowed("]"))
16..20: FootnoteReference(Borrowed("b")) // <---- footnote ref b
0..21: End(Paragraph)
22..42: Start(FootnoteDefinition(Borrowed("a")))
28..42: Start(Paragraph)
28..31: Text(Borrowed("Foo"))
31..32: SoftBreak
32..36: FootnoteReference(Borrowed("b"))
36..41: Text(Borrowed(": Bar"))
28..42: End(Paragraph)
22..42: End(FootnoteDefinition)
EOF
As well as the new (GFM) footnote parser:
➜ cargo run -- --events --enable-footnotes < in.md
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.07s
Running `/home/zoni/Workspace/pulldown-cmark/target/debug/pulldown-cmark --events --enable-footnotes`
0..21: Start(Paragraph)
0..12: Text(Borrowed("Lorem ipsum."))
12..13: Text(Borrowed("[")) // <---- footnote ref a incorrectly parsed as text
13..15: Text(Borrowed("^a"))
15..16: Text(Borrowed("]"))
16..20: FootnoteReference(Borrowed("b")) // <---- footnote ref b
0..21: End(Paragraph)
22..32: Start(FootnoteDefinition(Borrowed("a")))
28..32: Start(Paragraph)
28..31: Text(Borrowed("Foo"))
28..32: End(Paragraph)
22..32: End(FootnoteDefinition)
32..42: Start(FootnoteDefinition(Borrowed("b")))
38..42: Start(Paragraph)
38..41: Text(Borrowed("Bar"))
38..42: End(Paragraph)
32..42: End(FootnoteDefinition)
EOF
(Putting a space between [^a] and [^b] will produce correct events. The problem exists when two or more footnotes are squished up together. Then, only the last one is parsed correctly)
Footnotes
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels