Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin crashes when heading has no content #45

Closed
davidvandusen opened this issue May 28, 2018 · 2 comments
Closed

Plugin crashes when heading has no content #45

davidvandusen opened this issue May 28, 2018 · 2 comments

Comments

@davidvandusen
Copy link

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
> 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:

  • Node.js 10.2.1
  • markdown-it 8.4.1
  • markdown-it-toc-and-anchor 4.1.2
@allejo
Copy link

allejo commented Jul 13, 2018

This was introduced in #34 but still hasn't been fixed, see #34 (comment)

@medfreeman
Copy link
Owner

fixed in v4.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants