Only run on changed/new files

This commit is contained in:
askiiart 2023-09-11 20:23:28 -05:00
parent b00bc92482
commit 7d6e54cdb7
No known key found for this signature in database
GPG key ID: C89CBC4F981EE719

View file

@ -2,10 +2,12 @@
set -e set -e
dir=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd) dir=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
find . -name "*.md" | while read -r item ; do git status --porcelain | awk 'match($1, "(M|A|\?\?)"){print $2}' | while read -r item ; do
item="${item%.*}" if [[ ${item} == *.md ]]; then
echo "Currently processing ${item}" item="${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)" 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)"
fi
done done
find . \( ! -regex './md2html.sh' \) -type f | xargs sed -i 's/sourceCode /language-/g' find . \( ! -regex './md2html.sh' \) -type f | xargs sed -i 's/sourceCode /language-/g'