From d28e196e5a82dcecdd1a34a5c7327cd47ff4e477 Mon Sep 17 00:00:00 2001 From: Solomon Laing Date: Fri, 9 May 2025 15:32:53 +0930 Subject: [PATCH] simple script to convert html <--> markdown, I use to view pretty in lynx --- scripts/panmark | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 scripts/panmark 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 "$@"