Skip to content

feat(toc): add --bullet option for TOC entries - #182

Merged
ekalinin merged 2 commits into
masterfrom
feat/add-toc-bullet
Oct 27, 2026
Merged

ekalinin merged 2 commits into
masterfrom
feat/add-toc-bullet

Conversation

@ekalinin

Copy link
Copy Markdown
Owner

Summary

Fixes #71: a way to start TOC entries with a dash instead of an asterisk.

--bullet <CHAR> takes *, - or + (the three bullet markers of CommonMark) and
starts every bullet entry with it: - [Title](#title). The default stays *, so the
output without the option is the same as before.

  • gh-md-toc:
    • gh_toc_grab: the bullet is passed to the awk script with awk -v and replaces
      * in the entry marker. The script is shared by the default and OS/390 branches,
      so it applies to stdin, local files, remote URLs, several inputs, --insert and
      --numbered outline (- [2.1. Section](#section)).
    • gh_toc_app: --bullet is parsed right after --numbered and before -, in the
      existing fixed order of options, so --bullet - - reads stdin with dash bullets.
      gh_toc gets it as a new last (10th) parameter, read as ${10}.
    • Errors with exit code 1, before any network call: an unknown character, and
      --bullet with --numbered list (an ordered list has no bullet).
    • --help: a new line right after --numbered.
  • README.md: an example in "Local files" after the --numbered outline example,
    without a new heading, so the README TOC asserted in the tests does not change.
  • tests/tests.bats: tests for a local file with -, stdin with --bullet - -, +
    with --numbered outline, and both errors, on the existing fixtures; test_help
    updated.
  • openspec: the add-toc-bullet change (proposal, design, specs, tasks) is archived,
    with a new toc-bullet spec and "Hierarchical numbers" in toc-numbered updated for
    the bullet.

Not included: other bullet characters, a different bullet per level, a change of the
default, the --bullet=CHAR syntax.

Testing

  • The new tests and the updated help tests fail without the change; all 34 tests pass
    with it.
  • Checked manually: a remote URL with --bullet -, two local files with --bullet +,
    and --insert --no-backup with --bullet - on a copy of README.md.
  • make lint passes.

--bullet <CHAR> starts every bullet entry of the TOC with *, - or +
instead of *. It applies to every input and to --numbered outline.
An unknown character and --bullet with --numbered list exit with
code 1 before any network call.

Fixes #71
@ekalinin
ekalinin merged commit fe231ed into master Oct 27, 2026
1 check passed
@ekalinin
ekalinin deleted the feat/add-toc-bullet branch October 30, 2026 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add option to change the asterisk prefix to a dash

1 participant