Closed davidvandusen closed 5 years ago
When a heading has no content, the plugin crashes because it is trying to access properties of the child nodes of the heading, which don't exist.
Here is the output from a node session illustrating the issue.
node
$ node > const markdownIt = require('markdown-it') undefined > const markdownItTocAndAnchor = require('markdown-it-toc-and-anchor').default undefined > markdownIt().use(markdownItTocAndAnchor).render('## Real heading\n\n##\n\nEmpty heading above') TypeError: Cannot read property 'type' of undefined at Array.<anonymous> (/node_modules/markdown-it-toc-and-anchor/dist/index.js:55:53) at Core.process (/node_modules/markdown-it/lib/parser_core.js:51:13) at MarkdownIt.parse (/node_modules/markdown-it/lib/index.js:523:13) at MarkdownIt.render (/node_modules/markdown-it/lib/index.js:543:36)
The versions used are:
markdown-it
markdown-it-toc-and-anchor
This was introduced in #34 but still hasn't been fixed, see https://github.com/medfreeman/markdown-it-toc-and-anchor/pull/34#issuecomment-395389127
fixed in v4.2.0
When a heading has no content, the plugin crashes because it is trying to access properties of the child nodes of the heading, which don't exist.
Here is the output from a
node
session illustrating the issue.The versions used are:
markdown-it
8.4.1markdown-it-toc-and-anchor
4.1.2