Heading manager for markdown documents.
1. Markdown-TOC
2. Table of Contents
3. What it does
3.1. Heading numbers
3.2. Generate a TOC
4. Usage
5. Example
6. Known issues
7. TODO
7.1.
hack
7.2. "ignore-root" option
7.3. tolerate inconsistent depth
7.4. code documentation
7.5. tests
7.6. refactor main script file
//: # (/TOC)
This tool will remove any numbers after the "#" heading markers and replacing them with calculated ones
If there's a line "[TOC]" in the markdown, it will be replaced with a generated, anchor-linked TOC. Also, any existing TOC generated with this tool will be updated.
markdown-toc.rb [options] input.md [output.md]
Specific options: -s, --strip remove generated TOC content -a, --no-anchors e.g. gitlab mode: no hrefs for chapters -r, --replace replace input file
Common options: -h, --help Show this message
If OUTFILE
is omitted, the result will be printed to stdout.
You can also symlink this file for easier use: sudo ln -s PATH_TO_THIS_REPO/markdown-toc.rb /usr/bin/markdown-toc
This file has been generated from README_source.md
This is just a quick and dirty writeup, to be used as a small tool and for flexing my coding muscles. No real code documentation, no tests.
I couldn't get nested lists with depth > 2 to work with all markdown flavors (github, gitlub, markdown1).
The only way to enforce the indentation was to hardcode multiple
s. I might want to give this another try, because the way it's done now seems a bit WTF-y to me.
Often, everything is inside <h1>ProjectName</h1>
. This results in the undesirable behaviour of every subheading being prefixed with "1."
Be more forgiving: should allow depth jumps by more than 1. "####" as a child to "##" shouldn't trigger an error.
document in main file how code is organized internally
it's really not a quick hack anymore
toc handling and chapter numbers handling should become two distinct classes, called from main