feat: --toc-depth takes a level range like 2-6 - #12
Merged
Merged
Conversation
A lone N still means levels 1..N. A range N-M lists only levels N through M, inclusive — so 2-6 keeps everything except a level-1 document title, and 2-2 is level 2 alone. The window filters the TOC listing only; bookmarks keep every heading, and the settle loop needs no changes because the filter lives in toc_html. The library grows an additive toc_min_level kwarg on render and render_to_memory.
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.
What
--toc-depthnow also accepts a range:Nkeeps its meaning (levels 1..N), whileN-Mlists only levels N through M, inclusive.--toc --toc-depth 2-6— everything except a level-1 document title: the usual markdown book (H1 = title, H2 = chapters) gets a real TOC by default shape instead of a single self-referential entry--toc --toc-depth 2-2— chapter titles alone--toc --toc-depth 2-3— chapters and their sections, title skippedValidation is strict: integers 1..6, N ≤ M, and only the forms
NorN-M(3-2,2-7,0-2,2-,soon,2-2-2all abort with a usage message on stderr). No silent clamping.Semantics
mtoc-Nanchor numbering stays aligned because the filter lives intoc_html, not in the heading map.warn_missing_toclearned the range vocabulary: "--toc found no headings at depth 2-6" (loneNstill reads "at depth N").Library
Additive kwarg
toc_min_level : Int32 = 1onMarkd::Pdf.renderandrender_to_memory;settled_pagestakes it as a defaulted parameter before the block, so existing callers compile unchanged.Docs
Help text and the README docopt block were updated together and verified byte-identical to the actual
--helpoutput; the README TOC section documents the range form with the title-skip idiom.Verification
spec/pdf_toc_spec.cr: window filtering (including the "only level 2" case), nil when everything falls outside the window, a real two-pass render of a title+chapters+sections book attoc_depth: 3, toc_min_level: 2asserting the title stays out while every listed number matches the heading's true page, and a CLI spec covering2-6plus six rejected malformed values2-6and2-2renders,--print-configdumpingtoc_depth: 2-3, config-file roundtrip (toc-depth: 2-4read back), kdp + range with recto numbering, both warning paths, and the usage errors above