diff --git a/home/bin/custom/executable_markdown-fix-fenced-codeblocks.sh b/home/bin/custom/executable_markdown-fix-fenced-codeblocks.sh new file mode 100644 index 0000000000000000000000000000000000000000..3c699932d75d473127f0e6bb73bad4bfce7584b2 --- /dev/null +++ b/home/bin/custom/executable_markdown-fix-fenced-codeblocks.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +# Adds `sh` to the end of fenced codeblock beginnings in markdown files. + +set -euo pipefail + +src="$1" +tmp=$(mktemp) + +awk -v p='```' -v n="2" ' $0~p { i++ } ((i%n)==1) { sub(/^```/, "```sh") }{ print }' "$src" >"$tmp" +mv "$tmp" "$src"