diff --git a/scripts/panmark b/scripts/panmark new file mode 100755 index 0000000..66c6ddb --- /dev/null +++ b/scripts/panmark @@ -0,0 +1,30 @@ +#!/bin/bash + +# Simple script to convert html <-> markdown + +main() { + if [[ ! ( "$1" == *.md || "$1" == *.html ) ]]; then + echo "must provide *.md or *.html" + exit 1 + fi + + IFS=$'\n' read -d "" -ra tokens <<< "${1//./$'\n'}" + + input="" + output="" + + case ${tokens[1]} in + md) + input="${tokens[0]}.md" + output="${tokens[0]}.html" + ;; + html) + input="${tokens[0]}.html" + output="${tokens[0]}.md" + ;; + esac + + pandoc --from gfm --to html --standalone --output $output < $input +} + +main "$@"