markdown-it / markdown-it-footnote

Footnotes plugin for markdown-it markdown parser
https://markdown-it.github.io/
MIT License
210 stars 59 forks source link

erroneous markdown leads to crash #42

Closed ckruse closed 3 years ago

ckruse commented 3 years ago

Hi,

given this source code:

foo[^1] bar[^2].

[^1]:[^2]: baz

markdown-it-footnote fails with this error and stacktrace:

Uncaught TypeError: state.tokens[(state.tokens.length - 1)] is undefined
    footnote_tail index.js:338
    process parser_core.js:51
    parse index.js:524

While I understand that this is no valid markdown I don't think the parser should fail. Is this a bug?

Best regards, CK

puzrin commented 3 years ago

That's a bug. Markdown source can not be "invalid".

rlidwka commented 3 years ago

fixed, thanks for reporting

ckruse commented 3 years ago

Thank you very much for your work!