summaryrefslogtreecommitdiff
path: root/md.sh
diff options
context:
space:
mode:
authorSt33v <github@f3rr3t.com>2021-02-17 13:39:49 +1100
committerSt33v <github@f3rr3t.com>2021-02-17 13:39:49 +1100
commit8db6dbb4986ea705a5263b810c6cc3b2b75b4986 (patch)
tree4f44498f322f2b3f5b1724d6138a95f652bcec82 /md.sh
parent687279c79edda9eefb1c87d67264adcdabda45a9 (diff)
actually works, but hardcoded for firefox
Diffstat (limited to 'md.sh')
-rwxr-xr-x[-rw-r--r--]md.sh21
1 files changed, 18 insertions, 3 deletions
diff --git a/md.sh b/md.sh
index 09dcdb3..d197c13 100644..100755
--- a/md.sh
+++ b/md.sh
@@ -2,9 +2,24 @@
# Display a markdown file in a browser after converting it to HTML
# SJP 17 Feb 2021
#
-# stolen from https://unix.stackexchange.com/questions/24931/how-to-make-firefox-read-stdin/24942
+# stolen from https://unix.stackexchange.com/questions/24931/how-to-make-firefox-read-stdin/24942
-source = $1
+if [ $# -ne 1 ]; then
+ echo "Requires the name of one markdown file"
+ exit 1
+fi
-marked $source | firefox "data:text/html;base64,$(base64 -w 0 <&0)"
+if ! command -v marked &> /dev/null; then
+ echo "Install 'marked' before running this script"
+ exit 1
+fi
+if ! command -v firefox &> /dev/null; then
+ echo "Install 'firefox' before running this script"
+ exit 1
+fi
+
+
+echo there were $# arguments
+mdFile=$1
+marked ${mdFile} | firefox "data:text/html;base64,$(base64 -w 0 <&0)"