markdown-toc icon indicating copy to clipboard operation
markdown-toc copied to clipboard

Generated ToC includes commented headers

Open NathanielPerryAtAwatoXello opened this issue 3 years ago • 0 comments

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