The script will generate a TOC for a Markdown file, based on the headers in the file.
It generates and prints the TOC to the console, and optionally also inserts it into the original file.
For the latter, it will first create a backup copy of the file and then replace any section named "# Contents" with the new table of contents.
For the latter, it will first create a backup copy of the file and then replace any section named "# Contents" with the new table of contents **in the original input document**.
### Support for Table-of-Content Tags
Some renderers support special tags in the Markdown document to automatically insert a TOC. This script supports the following tags:
-`<!--TOC-->`
-`[TOC]`
-`[CONTENT]`
If the `--toctags` and `--add-content` options are specified, the script will replace these tags with the generated TOC in the original input document. To keep the original document intact, it may be a good idea to first create a backup copy of the document and work on that copy.