Monday, July 10, 2023

Markdown TOC Generator

The long wait is finally over! Announcing the most revolutionary innovation since punched cards! A command-line tool that inserts a table of contents into a markdown file!!!

(crickets)

Um ... according to my notes, this is where I'm supposed to wait for the cheering to die down.

(crickets get bored and leave)

Man, what a tough neighborhood.

Yeah, I know. There might be one or two similar tools out there. Like the web-based tool https://luciopaiva.com/markdown-toc/, but I don't like the cut-and-paste. Or the command-line tool at https://github.com/ekalinin/github-markdown-toc, but I don't like the curl dependency or the code (although credit to it for showing me the GitHub rendering API that I used in my test script).

So I wrote my own in Perl: https://github.com/fordsfords/mdtoc

Most of my other tools have either a build script or a test script; I'll probably change most of them to have something like:

# Update doc table of contents (see https://github.com/fordsfords/mdtoc).

if which mdtoc.pl >/dev/null; then mdtoc.pl -b "" README.md;

elif [ -x ../mdtoc/mdtoc.pl ]; then ../mdtoc/mdtoc.pl -b "" README.md;

else echo "FYI: mdtoc.pl not found; see https://github.com/fordsfords/mdtoc"

fi


No comments: