Skip to content

codegourmet/markdown-toc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

1. Markdown-TOC

Heading manager for markdown documents.

2. Table of Contents

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)

3. What it does

3.1. Heading numbers

This tool will remove any numbers after the "#" heading markers and replacing them with calculated ones

3.2. Generate a TOC

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.

4. Usage

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

5. Example

This file has been generated from README_source.md

6. Known issues

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.

7. TODO

7.1.   hack

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.

7.2. "ignore-root" option

Often, everything is inside <h1>ProjectName</h1>. This results in the undesirable behaviour of every subheading being prefixed with "1."

7.3. tolerate inconsistent depth

Be more forgiving: should allow depth jumps by more than 1. "####" as a child to "##" shouldn't trigger an error.

7.4. code documentation

document in main file how code is organized internally

7.5. tests

it's really not a quick hack anymore

7.6. refactor main script file

toc handling and chapter numbers handling should become two distinct classes, called from main

About

TOC generator and Heading numbering for Markdown files

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages