Repository navigation
Add --exclude option to leave out headings - #3
Merged
Merged
Conversation
Headings whose text matches are left out of the generated table of contents. Anchors are still counted over all headings, so links stay correct.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before
mdtoc always listed every heading it found. There was no way to keep a heading such as
Licenseout of the table of contents.After
--exclude TEXTleaves out every heading whose visible text is exactly TEXT (case-sensitive, surrounding spaces trimmed). The option can be repeated. Sub-headings stay, and anchors are still counted over all headings, so links such as#usage-1stay correct.An empty value (
--exclude "", a missing value,--exclude=) is rejected withmdtoc: --exclude requires a non-empty heading text.and exit code 1. It works with--check.How
src/cli.ts: parses the repeatable--excludeoption and passes it on.src/toc.ts: filters excluded headings when generating the table of contents, after anchors are computed.tests/cli.test.ts: 14 new tests (repeats, trimming, Setext and inline formatting, anchors, errors, excluding everything); one existing test was renamed to also cover the help text.README.md: new "Leave out headings" section and an options table row.