Notenik Knowledge Base

Back to Notenik.app

As an extension to the original Markdown spec from John Gruber, a Table of Contents for a single Note’s body field can be generated dynamically.

The generated HTML will display the ToC using unordered list tags, nesting where appropriate. Each ToC entry will link to its corresponding heading, relying on Heading ID Generation to establish the targets for the links.

Although dynamic Table of Contents generation for Markdown is a feature of great interest to many Markdown authors, there is unfortunately no standard syntax for extending Markdown to generate such a thing.

Notenik currently recognizes several different ways of invoking this feature.

1. Place the literal [toc] on a line by itself. This follows the Typora precedent.

2. Place the literal {:toc} on a line by itself. This follows the kramdown precedent.

3. Place the literal {{toc}} on a line by itself. This follows the MultiMarkdown precedent.

The resulting table will contain all of the headings found in the Markdown following the toc line itself.

If you wish to limit the heading levels included in the table of contents, place one or two digits following the toc literal. The first digit will be used as the logically highest (but numerically lowest) heading level to be included in the table of contents. For example, the digit ‘2’ will exclude level 1 headings from the table. The second digit will be used as the logically lowest (but numerically highest) heading level to be included.

For an example, see the following line:


{{toc:2-3}}


• Any Level 2 - 3 Headings preceding the toc line.
Note that, when using Merge Templates and converting Markdown to HTML, you will likely also need to use the Variable Modifier identified as the Wiki-Style Links Mod, typically with a value of ‘w2’, in order to make sure that this command resolves effectively, since it generates wiki-style links in Markdown before the conversion to HTML takes place.