From 0098c4174a88a00754edc3e028d6dff8ec6990ae Mon Sep 17 00:00:00 2001 From: c0de Date: Mon, 25 Jan 2021 11:36:47 -0600 Subject: [PATCH] Add markdown2html script --- home/bin/markdown2html | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 home/bin/markdown2html diff --git a/home/bin/markdown2html b/home/bin/markdown2html new file mode 100755 index 0000000..c155b06 --- /dev/null +++ b/home/bin/markdown2html @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +mkdir -p html + +REWRITE_LINKS=' +function Link(el) + el.target = string.gsub(el.target, "%.md", ".html") + return el +end +' + +md_to_html () { + filename=$(basename "$1" .md); + output_dir=$(dirname "$1") + mkdir -p "${output_dir}" + pandoc -s \ + -i "$1" \ + --include-in-header=github-pandoc.css \ + --file-scope \ + -f markdown+emoji \ + -t html \ + --lua-filter=<(echo "${REWRITE_LINKS}") \ + -o "${output_dir}/${filename}.html" +} + +export -f md_to_html + +find . -not -path './node_modules/*' -name "*.md" | while read -r f; do + md_to_html "${f}" +done +