Repository navigation
Add --insert option to add the marker pair - #5
Merged
Merged
Conversation
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.
Requested by gulliby
Before
A file without the
<!-- toc -->/<!-- tocstop -->markers was an error, so the first table of contents of a new README had to be started by hand.After
mdtoc --insert FILEadds the marker pair directly after the first level-1 ATX heading outside code fences (or at the start of the file when there is none) and then generates the entries. Files that already have markers are refreshed as before, so the command is safe to repeat; a file with only one marker is still an error.--insertcannot be combined with--checkor--print.How
src/toc.ts: new exportedinsertMarkers; the fence scanning is shared withextractHeadings.src/cli.ts: the--insertoption, its two conflicts, the usage text and the call.tests/insert.test.ts: new tests (158 tests pass in all);tests/print.test.tsonly has the usage line updated.README.md: option row, "Add the markers" section, updated missing-markers sentence.