From fca693f8cf2eeeae92939488b63127a90030c8fb Mon Sep 17 00:00:00 2001 From: thinkpadmaster Date: Thu, 13 Jul 2023 23:35:05 -0500 Subject: Extreme structure changes and file renames. Move to new template format. --- md/md2html.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 md/md2html.sh (limited to 'md/md2html.sh') diff --git a/md/md2html.sh b/md/md2html.sh new file mode 100755 index 0000000..d45f38d --- /dev/null +++ b/md/md2html.sh @@ -0,0 +1,17 @@ +#!/bin/bash +# converts md to .tmpl.html with pandoc + +readonly POSTS_DIR="../../html/posts" +readonly POST_TEMP="POST_TEMPLATE.tmpl.html" + +post=$(basename "$1" .md) +echo "converting $post to HTML" + +# pandoc for md to html +pandoc -f markdown-auto_identifiers -t html --template=$POST_TEMP --wrap=none -o "$POSTS_DIR/$post.tmpl.html" "$post".md + +# # adds in filename to path no longer needed +# sed -i "s/posts\//posts\/$post/" "$POSTS_DIR/$post.tmpl.html" + +# makes http & https links have target _blank and rel noopener noreferrer +perl -i -0pe 's/(<\W*a\W*[^>]*href=)(["'"'"']http[s]?:\/\/[^"'"'"'>]*["'"'"'])([^>]*>)/$1$2 target="_blank" rel="noopener noreferrer"$3/g' "$POSTS_DIR/$post.tmpl.html" \ No newline at end of file -- cgit v1.2.3