simple script to convert html <--> markdown, I use to view pretty in lynx

This commit is contained in:
Solomon Laing 2025-05-09 15:32:53 +09:30
parent 0eee62cfd5
commit d28e196e5a

30
scripts/panmark Executable file
View File

@ -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 "$@"