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

Error thrown when headers below level are present #7

Closed
alexkwolfe opened this issue Jul 29, 2015 · 2 comments
Closed

Error thrown when headers below level are present #7

alexkwolfe opened this issue Jul 29, 2015 · 2 comments

Comments

@alexkwolfe
Copy link

When rendering a document with headers that are below the specified level, an error is thrown. The below example illustrates the problem.

If the # Title declaration is removed, the error is no longer thrown. So it appears that headers below the specified level cause this error.

markdownIt = require('markdown-it')

content = """
# Title

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

## Sub Title

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

### Sub Sub Title

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
"""

rendered = markdownIt()
  .use require('markdown-it-anchor'), level: 2, permalink: true
  .render(content)

console.log rendered
@valeriangalliat
Copy link
Owner

Hi, thank you for reporting this, and sorry for the late reply!

This is a bug due to the permalink renderer being called for all headers regardless they match the level requirements.

Fixed with 2.2.1.

@alexkwolfe
Copy link
Author

No need to apologize! Thanks so much for all the work you've done on this module. 👍

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

2 participants