From d37a759e3aa0e9c56d5cdfecc8340b0c21546af2 Mon Sep 17 00:00:00 2001 From: Akemi Izuko Date: Sat, 23 Dec 2023 20:13:59 -0700 Subject: [PATCH] Add markdown table-of-contents parser --- bin/table_of_contents_markdown.awk | 89 ++++++++++++++++++++++++++++++ notes/shell/git_ssh.md | 8 +++ notes/shell/unix_bash.md | 20 ++++++- 3 files changed, 114 insertions(+), 3 deletions(-) create mode 100755 bin/table_of_contents_markdown.awk diff --git a/bin/table_of_contents_markdown.awk b/bin/table_of_contents_markdown.awk new file mode 100755 index 0000000..052d9de --- /dev/null +++ b/bin/table_of_contents_markdown.awk @@ -0,0 +1,89 @@ +#!/usr/bin/env -S awk -f +# Create a table of contents for a markdown file. Respects code blocks! +# +# ARGS (use these with -v[name]=[value] when calling): +# int heading : Indenting level for the "highest" heading. DEFAULT = 1 +# int table_only : Only print the table of contents. DEFAULT = 0 +# +# EXAMPLE RUN: +# $ table_of_contents_markdown.awk -vtable_only=1 -vheading=2 < uniques.txt Removes duplicate lines. This exploits awk's automatic initialization of variables with falsey values, 0 here, then turns that index truthy with `++` - - -