You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

27 lines
667 B

2 years ago
HEADER="$(dirname ${0})/header.html";
for MARKDOWN in ./*.md; do
CONVERT=0;
TITLE=$(grep '^# \S' ${MARKDOWN} | sed 's/# //g');
HTML="${MARKDOWN%.*}.html";
if [ ! -f ${HTML} ]; then
CONVERT=1;
elif [[ $(date -r ${MARKDOWN} +%s) > $(date -r ${HTML} +%s) ]]; then
CONVERT=1;
fi;
if [[ $CONVERT -eq 1 ]]; then
echo "Converting ${TITLE}";
`which pandoc` -s ${MARKDOWN} -H ${HEADER} -f markdown-task_lists --metadata pagetitle="${TITLE}" -o ${HTML};
fi;
done;
for HTML in ./*.html; do
HTML="${HTML/_p./}";
MARKDOWN="${HTML%.*}.md";
if [ ! -f ${MARKDOWN} ]; then
echo "Removing ${HTML}";
rm "${HTML}";
fi;
done;
sed -i ./*html -e 's/\.md/.html/g';