Table of contents in export

sahilagnihotri's Avatar


05 Oct, 2013 03:11 PM

Hey ,
i am having difficulty finding how to have table of contents in the HTML exported , i see it in preview in app but is there a way or a tag to have table of contents as apart of html (other than editing html) , pdf outputs .

Thanks and Regards,
Sahil Agnihotri

  1. Support Staff 1 Posted by Brett on 05 Oct, 2013 03:17 PM

    Brett's Avatar

    Try <!--TOC--> in the Markdown, it should do what you want. You can also use a max# parameter to control the depth of the TOC:

  2. 2 Posted by Rocketman on 06 Mar, 2014 09:29 AM

    Rocketman's Avatar

    I'm having the same problem. It prints the Table of contents fine. But when I export to HTML it does not work. I've added <!--TOC--> but it does not help.

  3. Support Staff 3 Posted by Brett on 06 Mar, 2014 01:50 PM

    Brett's Avatar

    TOC doesn't work in HTML export.

  4. 4 Posted by Rocketman on 06 Mar, 2014 02:53 PM

    Rocketman's Avatar

    Thanks, that's what I suspected. Would have been nice though.

  5. Support Staff 5 Posted by Brett on 06 Mar, 2014 03:01 PM

    Brett's Avatar

    The Table of Contents is generated by JavaScript, so if you needed to,
    you could actually embed the javascript in your exported documents. Let
    me know if that's something that would be workable for your needs and
    I'll look into making it possible.


  6. 6 Posted by Rocketman on 06 Mar, 2014 06:12 PM

    Rocketman's Avatar

    Thanks, that works fine. Powerful.

  7. 7 Posted by Jonathan on 21 Aug, 2015 09:24 PM

    Jonathan's Avatar

    Would it be possible to add a "embed TOC javascript" check to the HTML save box if you've either said to print TOC in prefs or added <!--TOC-->?

    Alternatively, add a checkbox to save to embed generated TOC HTML into the HTML export?

  8. Support Staff 8 Posted by Brett on 21 Aug, 2015 09:38 PM

    Brett's Avatar

    Next update will embed the TOC as actual HTML under those circumstances.

  9. 9 Posted by Jonathan Bennet... on 21 Aug, 2015 11:24 PM

    Jonathan Bennett's Avatar

    Thanks, brett!

    (Markdown + Marked2 n00b, and really appreciating the app)

  10. 10 Posted by btoone on 23 Aug, 2015 03:59 PM

    btoone's Avatar

    Hi just a follow-up question to this. After reading I'm wondering if there is a way to make the table of contents show when exporting to HTML but not in preview. In other words, I'd like to use the cmd+T window while previewing but have links at the top when exporting.

    When I have the "Print table of contents" box checked it behaves this way for printing, just not exporting to HTML.

  11. Support Staff 11 Posted by Brett on 23 Aug, 2015 04:16 PM

    Brett's Avatar

    Not for HTML export. "Print TOC" only affects print and PDF export. HTML
    export only gets what's in the preview right now.

    It's possible to apply some CSS using the "Additional CSS" in Style
    preferences to hide elements in the preview that aren't hidden in export
    because Marked applies some special classes during preview. However,
    these are dependent on the current theme, so the rule would have to be
    repeated if you use multiple themes. Here's an example:

    .mkstyle--swiss #mkreplaced-toc {
       display: none!important;

    The 'mkstyle--swiss' class is not exported, so the rule would have no
    effect in HTML outside of Marked. It's not an ideal solution, but it's
    assumed that if you want a manually-inserted TOC, you want it in both
    places, and there's currently no option to automatically generate one
    during export because it's generating the exported HTML prior to display
    in the preview window, and the TOC is generated with JavaScript within
    the preview.


  12. 12 Posted by btoone on 23 Aug, 2015 04:54 PM

    btoone's Avatar

    Great, thanks for the clarification and work-around.

  13. 13 Posted by Hans on 04 Jan, 2016 03:43 PM

    Hans's Avatar

    With <!--TOC--> I can create a Table of Contents, which is beautifully exported to PDF. However, when I click on an item of this TOC in the PDF, there is no jump to the corresponding chapter. Is it possible to have this working?

  14. Support Staff 14 Posted by Brett on 04 Jan, 2016 05:09 PM

    Brett's Avatar

    @info: please see this discussion

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac