markdown-it / markdown-it-footnote

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

Crashing on .parse() #40

Closed VladimirCharkot closed 3 years ago

VladimirCharkot commented 3 years ago
> let markdownIt = require('markdown-it')
> let markdownItFootnote = require('markdown-it-footnote')
> let md = markdownIt()
> md.parse('')
[]
> md.use(markdownItFootnote)
> md.parse('')
Uncaught TypeError: Cannot read property 'footnotes' of undefined
    at Array.footnote_tail (/Users/vlad/Documents/Codes/esde/node_modules/markdown-it-footnote/index.js:293:20)
    at Core.process (/Users/vlad/Documents/Codes/esde/node_modules/markdown-it/lib/parser_core.js:51:13)
    at MarkdownIt.parse (/Users/vlad/Documents/Codes/esde/node_modules/markdown-it/lib/index.js:523:13)
> md.render('')
''

I have to disable markdown-it-footnote if I need to work with the token stream. Is this intended?

Thanks!

VladimirCharkot commented 3 years ago

The crash occurs trying to access state.env.footnotes as state.env is undefined

puzrin commented 3 years ago

.parse MUST have second param. See src & api docs.