From 9305040da475b3f1a25158e4b8b8c351abef2d28 Mon Sep 17 00:00:00 2001 From: askiiart Date: Mon, 11 Sep 2023 20:10:21 -0500 Subject: [PATCH] Remove python script with bash script --- md2html.py | 13 ------------- md2html.sh | 11 +++++++++++ 2 files changed, 11 insertions(+), 13 deletions(-) delete mode 100755 md2html.py create mode 100755 md2html.sh diff --git a/md2html.py b/md2html.py deleted file mode 100755 index f64cee9..0000000 --- a/md2html.py +++ /dev/null @@ -1,13 +0,0 @@ -import os -from pathlib import Path - -dir = os.path.dirname(__file__) -print(dir) -os.chdir(dir) -files = [str(item)[:-3] for item in Path(dir).rglob('*.md')] - -for item in files: - os.system(f'pandoc -f markdown-smart --data-dir . --template {dir}/template.html -t html -o {item}.html {item}.md --metadata title=\"$(grep -m 1 -oP \'(?<=^# ).*\' {item}.md | cat)\"') - -# Replace 'language-' with 'language-' recursively -os.system("find . \( ! -regex './md2html.py' \) -type f | xargs sed -i 's/sourceCode /language-/g'") diff --git a/md2html.sh b/md2html.sh new file mode 100755 index 0000000..60f9694 --- /dev/null +++ b/md2html.sh @@ -0,0 +1,11 @@ +#!/bin/bash +set -e +dir=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd) + +find . -name "*.md" | while read -r item ; do + item="${item%.*}" + echo "Currently processing ${item}" + pandoc -f markdown-smart --data-dir . --template ${dir}/template.html -t html -o ${item}.html ${item}.md --metadata title="$(grep -m 1 -oP '(?<=^# ).*' ${item}.md | cat)" +done + +find . \( ! -regex './md2html.sh' \) -type f | xargs sed -i 's/sourceCode /language-/g' \ No newline at end of file