You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If there is a way to generator TOC automatically. Or, I just type [toc] in the first line,it will turn to A catalog and update while content is changing.
Reacted by Isaac Daly, Snuupy, schlegan, tiptoptom, Carefree Lu and Callisto88
I think there's an easier way to set a TOC within the text editor, like the VSCode extension does. Instead of adding a HTML string, just add more Markdown stuff inside some marked comments.
TOC is not defined in GFM, so I suggest to only add this as export option. Because how do you want to keep the table of contents up-to-date if there is already one inserted. You have to delete the old one and insert it again.
An export option for instance by replacing a special string like %TOC-H3% with the markdown representation of all headlines down to level 3 would be easier. A live representation is already there, so we don't need it twice.
But this is a non-critical feature, it does not make Mark Text more stable. Why is it selected for A more stable Mark Text . How about adding adding a Feature Wishlist project for the fun stuff.
Why hasn't the TOC function been implemented?
Because I haven’t discovered the TOC in other places so far, I have not add it to Mark Text.
As you said, it does not belong to A more stable Mark Text .
@Jocs Why was this issue closed, it's still not implemented? I think it would be a good idea and would definitely prefer @gitfineon idea to generate the TOC when exporting a document to HTML/PDF and replace the [TOC] tag. Otherwise we should mark this as plugin.
TOC is not defined in GFM, so I suggest to only add this as export option. Because how do you want to keep the table of contents up-to-date if there is already one inserted. You have to delete the old one and insert it again.
An export option for instance by replacing a special string like %TOC-H3% with the markdown representation of all headlines down to level 3 would be easier. A live representation is already there, so we don't need it twice.
@fxha Yes, it is not implemented, because TOC is not the syntax in the GFM standard, and we also implemented TOC navigation in the sidebar, so I thought it was not necessary to implement it. When exporting, I think we can add an option. Whether to export the TOC. This is a good idea, maybe add it later when optimizing the export feature.
Reacted by GitFiNeon, Jiawei, Adrien Beau, Jack Ma, Andrii Oriekhov, Cyril SANTUNE, Ivan Ionut, YalandHong and Junyu
@fxha Yes, it is not implemented, because TOC is not the syntax in the GFM standard, and we also implemented TOC navigation in the sidebar, so I thought it was not necessary to implement it. When exporting, I think we can add an option. Whether to export the TOC. This is a good idea, maybe add it later when optimizing the export feature.
The GFM should be considered minimal requirements, not maximum allowed. Additional features will not harm its use. There are other additional features in Marktext that are not part of GFM so I don't see why this can't be an editor feature. The sidebar navigation feels very much like an addon and removes the clean interface of seeing only the document itself how the author intended. Many documents are created using [TOC] which is supported on other editors.
I also hope it doesn't define the maximum that is possible. A [TOC] that is visible while editing, updates itself and also appears in an export would be really nice (I don't like the sidebar opened while writing as well).
Edit: @DutchPete Yes they have done an awesome job and I don't think anyone wants to complain here.
I think it should be possible to discuss features in an open source community though.
Dorian-DS expresses a valid view in my opinion and I would as well prefer to have a [TOC]-element like e.g. Typora,
Reacted by EJ Makela, Trent Holliday, Pietro Nardelli and SnowCode
I already have a basic implementation for this locally and can create a draft PR in the following days. It's not feature rich but works for navigating the file.
Could Mark Text export pdf with the index?
What I mean is not the content table in document but the index info that could be recognized by the pdf viewer which will show it on the side bar.
Reacted by DYH-Hong, z4deepfz, YalandHong, Žiga Lausegger, tiptoptom, Santiago de la cruz Martinez Lara and cycychenyi
Reacted by Fernando Basso, DYH-Hong, Jinmin CHEN, YalandHong, tiptoptom, Žiga Lausegger, secnigma, Santiago de la cruz Martinez Lara and Léo Géré
Reacted by Fernando Basso, DYH-Hong, Jinmin CHEN, rosedance, YalandHong, shaopi0211, Žiga Lausegger and Santiago de la cruz Martinez Lara
Please give us a choice in Preference to enanle [toc] on Editor. It's simply a pain to go deal with a big markdown without [toc] jumps. Otherwise I may have to find another alternative...
GitLab has [TOC] implemented now. Would be really helpful to see it implemented in marktext, since I'm writeng quite extensive documentations for my projects.
I'd love to see it. Otherwise marktext is a really awesome editor.
Thank you for this request. Both of the features discussed in this thread are now implemented in MarkText:
TOC navigation sidebar — a live, collapsible table of contents panel in the side bar tracks headings as you edit (View → Toggle Side Bar).
TOC in HTML/PDF export — if your document contains a standalone [TOC] line, it is replaced with a fully linked table of contents in the exported HTML/PDF. The export settings dialog lets you control whether the top-level heading is included and set a custom title for the TOC section.
These features are backed by the muya.getTOC() API in the new editor engine (packages/muya/src/state/getTOC.ts) and wired into the export pipeline in packages/desktop/src/renderer/src/util/exportHtml.ts and pdf.ts.
Closing as already implemented. If you encounter a specific gap or regression, please open a new issue with reproduction steps and the MarkText version.
Activity
joe223 commentedon Mar 26, 2018
weird, I can not add a Label.
Jocs commentedon Mar 26, 2018
@joe223 Do you mean to write HTML directly in Mark Text?
joe223 commentedon Mar 26, 2018
@Jocs just write
[TOC].example markdown content:
finally, we got
Jocs commentedon Mar 26, 2018
joe223 commentedon Mar 27, 2018
Only owner can set this.
khaosdoctor commentedon Apr 13, 2018
I think there's an easier way to set a TOC within the text editor, like the VSCode extension does. Instead of adding a HTML string, just add more Markdown stuff inside some marked comments.
gitfineon commentedon Jun 29, 2018
TOC is not defined in GFM, so I suggest to only add this as export option. Because how do you want to keep the table of contents up-to-date if there is already one inserted. You have to delete the old one and insert it again.
An export option for instance by replacing a special string like
%TOC-H3%with the markdown representation of all headlines down to level 3 would be easier. A live representation is already there, so we don't need it twice.But this is a non-critical feature, it does not make Mark Text more stable. Why is it selected for A more stable Mark Text . How about adding adding a Feature Wishlist project for the fun stuff.
Jocs commentedon Jun 29, 2018
Why hasn't the TOC function been implemented?
Because I haven’t discovered the TOC in other places so far, I have not add it to Mark Text.
As you said, it does not belong to A more stable Mark Text .
fxha commentedon Jan 18, 2019
@Jocs Why was this issue closed, it's still not implemented? I think it would be a good idea and would definitely prefer @gitfineon idea to generate the TOC when exporting a document to HTML/PDF and replace the
[TOC]tag. Otherwise we should mark this asplugin.[-]Support TOC[/-][+]Generate TOC when exporting to HTML/PDF[/+]Jocs commentedon Jan 24, 2019
@fxha Yes, it is not implemented, because TOC is not the syntax in the GFM standard, and we also implemented TOC navigation in the sidebar, so I thought it was not necessary to implement it. When exporting, I think we can add an option. Whether to export the TOC. This is a good idea, maybe add it later when optimizing the export feature.
5 remaining items
dakira commentedon Nov 4, 2019
@Jocs There doesn't need to be any extra syntax. Just ask if a TOC should be included on export. stackedit.io allows for this:
The result adds a navigational sidebar to the html like this:
tweinreich commentedon Nov 7, 2019
I also hope it doesn't define the maximum that is possible. A
[TOC]that is visible while editing, updates itself and also appears in an export would be really nice (I don't like the sidebar opened while writing as well).Edit:
@DutchPete Yes they have done an awesome job and I don't think anyone wants to complain here.
I think it should be possible to discuss features in an open source community though.
Dorian-DS expresses a valid view in my opinion and I would as well prefer to have a
[TOC]-element like e.g. Typora,kataras commentedon Nov 9, 2020
Hello,
This feature is not yet implemented? I am trying for hours to find a way to generate a TOC here...
fxha commentedon Nov 13, 2020
I already have a basic implementation for this locally and can create a draft PR in the following days. It's not feature rich but works for navigating the file.
CrystalRays commentedon Jun 29, 2021
Could Mark Text export pdf with the index?
What I mean is not the content table in document but the index info that could be recognized by the pdf viewer which will show it on the side bar.
kouichi-c-nakamura commentedon Nov 26, 2021
Please give us a choice in Preference to enanle [toc] on Editor. It's simply a pain to go deal with a big markdown without [toc] jumps. Otherwise I may have to find another alternative...
qds-soft commentedon Jan 21, 2022
GitLab has [TOC] implemented now. Would be really helpful to see it implemented in marktext, since I'm writeng quite extensive documentations for my projects.
I'd love to see it. Otherwise marktext is a really awesome editor.
weironz commentedon Apr 11, 2022
WE NEED IT ,THANKS
SekoiaTree commentedon Apr 11, 2022
I dug through the code a bit; even though the implementation for exports is "there", it seems that the option is disabled. Is that intentional?
marktext/src/renderer/util/pdf.js
Line 93 in 2bb405a
tocListis empty, and that method is called bymarktext/src/renderer/util/pdf.js
Line 120 in 2bb405a
tocis passed to generateHtmlToc.This is then called by
marktext/src/renderer/components/editorWithTabs/editor.vue
Line 942 in 2bb405a
this.editor.toc, which is created bymarktext/src/renderer/components/editorWithTabs/editor.vue
Line 552 in 2bb405a
Several places also use
marktext/src/muya/lib/utils/exportHtml.js
Line 133 in 2bb405a
2catycm commentedon Jun 23, 2022
Hello,
This feature is not yet implemented? I am trying for hours to find a way to generate a TOC too.
allenzt commentedon Jul 14, 2022
Hi guys, thanks for your excellent work! Do you have any update?
DutchPete commentedon Jul 14, 2022
@allenzt have a look at this: #1290 (comment)
Jocs commentedon Jun 26, 2026
Thank you for this request. Both of the features discussed in this thread are now implemented in MarkText:
TOC navigation sidebar — a live, collapsible table of contents panel in the side bar tracks headings as you edit (View → Toggle Side Bar).
TOC in HTML/PDF export — if your document contains a standalone
[TOC]line, it is replaced with a fully linked table of contents in the exported HTML/PDF. The export settings dialog lets you control whether the top-level heading is included and set a custom title for the TOC section.These features are backed by the
muya.getTOC()API in the new editor engine (packages/muya/src/state/getTOC.ts) and wired into the export pipeline inpackages/desktop/src/renderer/src/util/exportHtml.tsandpdf.ts.Closing as already implemented. If you encounter a specific gap or regression, please open a new issue with reproduction steps and the MarkText version.
Ken-Leo commentedon Sep 4, 2026
Even so, the exported PDF files DO NOT have page numbering in the TOC and just dots. Would this be addressed in the future?