Skip to content

Generated ToC includes commented headers #178

@NathanielPerryAtAwatoXello

Description

markdown-toc will include headers that are inside of HTML comments (<!-- comment -->), as is allowed in GitHub Flavored Markdown.

Steps to reproduce

sample.md

# Header 1 listed

<!--
# Header 2 unlisted
-->

# Header 3 listed

Then run: npx markdown-toc sample.md

Actual result

- [Header 1 listed](#header-1-listed)
- [Header 2 unlisted](#header-2-unlisted)
- [Header 3 listed](#header-3-listed)

Expected result

- [Header 1 listed](#header-1-listed)
- [Header 3 listed](#header-3-listed)

Workaround

# Header 1 listed

<!--
```
# Header 2 unlisted
```
-->

# Header 3 listed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions