Repository navigation
feat(toc): add --skip-no-markers to skip files without markers - #199
Merged
Merged
Conversation
This was referenced Nov 7, 2026
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.
Summary
Fixes #110: a way to run
--inserton all markdown files of a directory.Today
--insertwith several local files stops at the first file without the<!--ts-->and<!--te-->markers: it exits with 1, and the files after it are notprocessed, even when they have the markers. The markers are checked after the GitHub API
request, so the request for that file is spent too.
--skip-no-markersskips such a file instead:--skip-no-markersa.md(markers),b.md(none),c.md(markers)a.md, error forb.md,c.mdnot processed, exit 1a.mdandc.md,b.mdnot changed, exit 0b.mdb.md: Warning: no <!--ts--> or <!--te--> in the file, skippedWith
find, this also covers the first request of #110, the recursive folders:Changes:
gh-md-toc:gh_toc: with the option, a local input that is an existing file is checked forthe marker lines (the same regexes as
--insert, seetoc-markers) right at thestart, before the "Table of Contents" header and the GitHub API request. Without
them, the warning goes to stderr and the function returns, so the loop goes on to
the next input. The option is a new last (11th) parameter.
-are not skipped: they go the same way as beforeand exit with 1, so a typo in a CI command does not pass with exit 0.
gh_toc_app:--skip-no-markersis parsed right after--hide-footerand turns on--insert, as--no-backupand--hide-footerdo. With--stdoutit is an erroron stderr with exit code 1, before any network call.
--help: a new line right after--hide-footer.README.md: a sentence and thefindexample in "Auto insert and update TOC",without a new heading, so the README TOC asserted in the tests does not change.
tests/tests.bats: 6 tests on files in$BATS_TEST_TMPDIR(several files, one filewith one marker and an invalid token, a missing file, the option alone, several files
without the option, the error with
--stdout);test_helpupdated.openspec: theadd-skip-no-markerschange (proposal, design, specs, tasks), notarchived yet. It adds the
toc-skip-no-markersspec and updates "Help lists theoption" in
toc-stdout:--stdoutfollows--skip-no-markersin--helpnow.Without
--skip-no-markers, the output, the exit codes and the stop at the first filewithout markers do not change.
Not included: a directory walk in
gh-md-tocitself (--all), adding the markers to afile (
--auto,--headof #117), skipping by default, a version bump.Testing
for a missing file and for several files without the option pass, they pin down the
behavior that does not change. All 71 tests pass with the change (macOS, BSD awk
20200816).
findexample in a temporary directory witha.md,sub/c.md(with markers) andb.md(without), and the option with the remotesitemap.js README (TOC and
!! ... is not a local file, exit 0).make lintpasses.