From 84c93a637143879c845152c7ecab0d3e8f986585 Mon Sep 17 00:00:00 2001 From: Akemi Izuko Date: Mon, 21 Nov 2022 18:22:18 -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 `++` - - -