This is a small node script to preprocess and create table of contents for markdown documents. It examines the document you pass to it, creates a table of contents based on your titles, and inserts it instead of every line that contains '@@TOC@@'
Small and simple README.md preprocessor for creating table of contents.
Say you've got a README.md file with lots of information, and you want to create a table of contents with reference links
This script will help you to do so. It extracts information of titles in a given file, and inserts a formatted table of contents in the position, specified by "@@TOC@@" line.
node toc.js README.md > NEW_README.md
# Foo Great ProjectHey, this is my project## Contents@@TOC@@## AboutSome info about it## AuthorsMy picture here
Will be transformed to
# Foo Great ProjectHey, this is my project## Contents- [Foo Great Project](#foo-great-project)- [Contents](#contents)- [About](#about)- [Authors](#authors)## AboutSome info about it## AuthorsMy picture here
After the preprocessing you're free to modify the result as you wish. For example, it makes sense to remove reference to table of contents from table of contents
The script doesn't support underlined titles like this
Use sharps instead
# My Title