#!/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 "$@"