40 lines
1.4 KiB
Bash
40 lines
1.4 KiB
Bash
|
|
#!/bin/bash
|
||
|
|
|
||
|
|
if ! [[ "$1" =~ ^(src-md|md-html|src-cc-html|src-html|html-txt) ]]; then
|
||
|
|
echo "usage: $0 [action] [files...]"
|
||
|
|
echo "where action can be: [src-md|md-html|src-cc-html|src-html]"
|
||
|
|
exit 1
|
||
|
|
fi
|
||
|
|
|
||
|
|
if [[ $# -lt 2 ]]; then
|
||
|
|
echo "wrong number of parameters (need at least a command and an input file)"
|
||
|
|
exit 2
|
||
|
|
fi
|
||
|
|
|
||
|
|
case $1 in
|
||
|
|
|
||
|
|
src-md)
|
||
|
|
echo "converting input file to md (via pandoc)"
|
||
|
|
pandoc --wrap=none -t markdown "${@:2}" -o "${@:2}".md
|
||
|
|
;;
|
||
|
|
md-html)
|
||
|
|
echo "converting md input file to html"
|
||
|
|
pandoc --wrap=none --standalone --mathjax=https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js "${@:2}" -o "${@:2}".html
|
||
|
|
;;
|
||
|
|
src-cc-html)
|
||
|
|
echo "converting src input file to CC html"
|
||
|
|
pandoc --wrap=none -t markdown "${@:2}" -o "${@:2}".md
|
||
|
|
python format-cc-notes.py -t "${@:2}".md -o "${@:2}".html.md -f cc
|
||
|
|
pandoc --wrap=none --template ./template.html --mathjax=https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js "${@:2}".html.md -o "${@:2}".CC.html
|
||
|
|
rm "${@:2}".html.md
|
||
|
|
rm "${@:2}".md
|
||
|
|
;;
|
||
|
|
src-html)
|
||
|
|
echo "converting src input file to bare html"
|
||
|
|
pandoc --wrap=none -t markdown "${@:2}" -o "${@:2}".md
|
||
|
|
python format-cc-notes.py -t "${@:2}".md -o "${@:2}".html.md -f html
|
||
|
|
pandoc --wrap=none --template ./template.html --mathjax=https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js "${@:2}".html.md -o "${@:2}".html
|
||
|
|
rm "${@:2}".html.md
|
||
|
|
rm "${@:2}".md
|
||
|
|
;;
|
||
|
|
esac
|