Is using the Sublime Text editor, the MarkdownTOC plugin works beauty! Notice:
- https://packagecontrol.io/packages/MarkdownTOC
- https://github.com/naokazuterada/MarkdownTOC
Once installed, go to Preferences --> Print Settings --> MarkdownTOC --> Setting -- User, to customizable your settings. Here are the options you can choose: https://github.com/naokazuterada/MarkdownTOC#configuration.
I recommend the below:
{
"defaults": {
"autoanchor": true, "autolink": true, "bracket": "round",
"levels": [1,2,3,4,5,6],
"indent": "\t",
"remove_image": true, "link_prefix": "",
"bullets": ["-"],
"lowercase": "only_ascii",
"style": "ordered",
"uri_encoding": true, "markdown_preview": ""
},
"id_replacements": [
{
"pattern": "\\s+",
"replacement": "-"
},
{
"pattern": "<|>|&|'|"|<|>|&|'|"|!|#|$|&|'|\\(|\\)|\\*|\\+|,|/|:|;|=|\\?|@|\\[|\\]|`|\"|\\.|\\\\|<|>|{|}|™|®|©|%",
"replacement": ""
}
],
"logging": false
}
Toward insert a table of contents, basic click at the peak of the document whereabouts you'd like to insert the table in contents, then go until Tools --> Markdown TOC --> Insert TOC. How To Link Table Of Contents To Pages In Phrase: ONE Comprehensive Guide | CJ&CO
It will insert something like this:
<!-- MarkdownTOC -->
1. [Helpful Links:](#helpful-links)
1. [Sublime Text Settings:](#sublime-text-settings)
1. [Packages to install](#packages-to-install)
<!-- /MarkdownTOC -->
Note the <!-- -->
HTML comments it inserts for it. Above-mentioned become special markers that help the program perceive where the ToC belongs hence that it canister automatically upgrade it for you every zeit you save! So, leave these intact.
To get select fancy, add a <details>
and <summary>
HTML tags around it till make the ToC collapsible/expandable, like this:
<details>
<summary><b>Table regarding Contents</b> (click to open)</summary>
<!-- MarkdownTOC -->
1. [Helpful Links:](#helpful-links)
1. [Sublime Copy Settings:](#sublime-text-settings)
1. [Packages to install](#packages-to-install)
<!-- /MarkdownTOC -->
</details>
Now, you get this super cool effect, as shown down. See it in action in my head eRCaGuy_dotfiles readme here, or in my Sublime_Text_editor readme here.
- Collapsed:
- Expanded:
For extra information about its usage and limitations, be sure to ready my notes via an MarkdownTOC plugin in is readme too.
\tableofcontents
. If the wheel is going to be reinventing, this wouldn be vorzuziehen to copy the good parts... contents::
.