Repository navigation
Specify the TOC level within the document #2938
|
Is it possible to specify within the document which heading levels the table of contents should display? |
Replies: 4 comments 1 reply
|
Have you checked Markor settings?
|
|
Yes Gregor
This enable the level for every document.
I would like to modify the toc level for one given document
Le mar. 27 oct. 2026, 07:59, Gregor Santner ***@***.***> a
écrit :
… Have you checked Markor settings?
—
Reply to this email directly, view it on GitHub
<#2938?email_source=notifications&email_token=A4L7RNMXAJUWDPRQXX44N535WBBULA5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCOJSGEYTMMZTUZZGKYLTN5XKMYLVORUG64VFMV3GK3TUVRTG633UMVZF6Y3MNFRWW#discussioncomment-19211633>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A4L7RNOOQIQ6WXUQ333VW235WBBULAVCNFSNUABIKJSXA33TNF2G64TZHMYTAMJUGUYTANBSHNCGS43DOVZXG2LPNY5TCMJRGM4TANRZUF3AE>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/A4L7RNOEUC27QZPXQQJDYCL5WBBULA5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCOJSGEYTMMZTUZZGKYLTN5XKMYLVORUG64VFMV3GK3TUVJTG633UMVZF62LPOM>
and Android
<https://github.com/notifications/mobile/android/A4L7RNMKQ6MQD5FJFSJWWT35WBBULA5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCOJSGEYTMMZTUZZGKYLTN5XKMYLVORUG64VFMV3GK3TUVZTG633UMVZF6YLOMRZG62LE>.
Download it today!
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
|
Yes. Markor understands flexmark's "sim TOC" line, so you can set the TOC levels for one document by putting this on its own line where the TOC should appear: That document then gets a TOC with only its
The line has the form of a Markdown link reference definition, so other Markdown viewers simply hide it. Why this works: Markor always enables both flexmark TOC extensions (L142-L143). The setting only decides whether Markor inserts its own One catch: when the TOC setting is on, Markor only skips its own TOC if the document contains the exact text
Option 2 depends on that text check, so it could stop working if Markor changes it. I tested this with flexmark 0.64.8 (the version Markor uses), with the TOC part of Markor's converter copied from v2026.10.0:
|
|
Thank you for this precise and comprehensive response. No surprise that
Markor is such an excellent application.
🙏🙏🙏
Le mer. 4 nov. 2026, 14:33, Daliik ***@***.***> a écrit :
… Yes. Markor understands flexmark's "sim TOC" line, so you can set the TOC
levels for one document by putting this on its own line where the TOC
should appear:
[TOC levels=2-3]: #
That document then gets a TOC with only its ## and ### headings. With
nothing after #, the TOC gets a "Table of contents" heading (Markor's
translated string). Variants:
- [TOC levels=2-3]: # "Contents" uses your own title.
- [TOC levels=2-3]: # '' drops the title and shows just the list, the
same as the line Markor inserts itself.
- levels=1-3, levels=2-4, etc. work as ranges. A single number above 2
means "from 2 up to that" (flexmark
<https://github.com/vsch/flexmark-java/blob/bcfe84a3ab6d23d04adce3e5a0bae45c6b791d14/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/internal/TocLevelsOptionParser.java#L86-L94>),
so levels=3 means 2-3, not 1-3.
The line has the form of a Markdown link reference definition, so other
Markdown viewers simply hide it.
Why this works: Markor always enables both flexmark TOC extensions (
L142-L143
<https://github.com/gsantner/markor/blob/04e8b92ab51ef950df5dc6efb4e21d2f1d43280c/app/src/main/java/net/gsantner/markor/format/markdown/MarkdownTextConverter.java#L142-L143>).
The setting only decides whether Markor inserts its own [TOC]: # '' line
and which levels are the default (L259-L280
<https://github.com/gsantner/markor/blob/04e8b92ab51ef950df5dc6efb4e21d2f1d43280c/app/src/main/java/net/gsantner/markor/format/markdown/MarkdownTextConverter.java#L259-L280>).
The levels= in your line overrides that default.
One catch: when the TOC setting is on, Markor only skips its own TOC if
the document contains the exact text [TOC]: # (L260
<https://github.com/gsantner/markor/blob/04e8b92ab51ef950df5dc6efb4e21d2f1d43280c/app/src/main/java/net/gsantner/markor/format/markdown/MarkdownTextConverter.java#L260>).
[TOC levels=2-3]: # doesn't contain it, so you'd get two TOCs: Markor's
at the top and yours. You have two options:
1. Turn the TOC setting off (no levels ticked) and add the line only
to the documents that should have a TOC.
2. Keep the setting on and add an invisible comment to that document
so Markor doesn't insert its own TOC:
<!-- [TOC]: # -->
[TOC levels=2-3]: #
Option 2 depends on that text check, so it could stop working if Markor
changes it.
I tested this with flexmark 0.64.8 (the version Markor uses), with the TOC
part of Markor's converter copied from v2026.10.0:
- Setting off: one TOC with h2-h3.
- Setting on with levels 1-3: two TOCs.
- Setting on, with the comment: one TOC with h2-h3.
—
Reply to this email directly, view it on GitHub
<#2938?email_source=notifications&email_token=A4L7RNNFUHBP6P3WQIMKSSD5XMV37A5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCOJTHE4DCOBQUZZGKYLTN5XKMYLVORUG64VFMV3GK3TUVRTG633UMVZF6Y3MNFRWW#discussioncomment-19398180>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A4L7RNMOHJW5B2JJCFGA4H35XMV37AVCNFSNUABIKJSXA33TNF2G64TZHMYTAMJUGUYTANBSHNCGS43DOVZXG2LPNY5TCMJRGM4TANRZUF3AE>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/A4L7RNNCSNN5NFYPC7GD5JL5XMV37A5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCOJTHE4DCOBQUZZGKYLTN5XKMYLVORUG64VFMV3GK3TUVJTG633UMVZF62LPOM>
and Android
<https://github.com/notifications/mobile/android/A4L7RNPM4CJTKGSFQSI7LTD5XMV37A5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCOJTHE4DCOBQUZZGKYLTN5XKMYLVORUG64VFMV3GK3TUVZTG633UMVZF6YLOMRZG62LE>.
Download it today!
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Yes. Markor understands flexmark's "sim TOC" line, so you can set the TOC levels for one document by putting this on its own line where the TOC should appear:
That document then gets a TOC with only its
##and###headings. With nothing after#, the TOC gets a "Table of contents" heading (Markor's translated string). Variants:[TOC levels=2-3]: # "Contents"uses your own title.[TOC levels=2-3]: # ''drops the title and shows just the list, the same as the line Markor inserts itself.levels=1-3,levels=2-4, etc. work as ranges. A single number above 2 means "from 2 up to that" (flexmark), solevels=3means 2-3, not 1-3.The line has the form of a Markdown link refer…