summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSt33v <github@f3rr3t.com>2021-02-17 13:49:00 +1100
committerSt33v <github@f3rr3t.com>2021-02-17 13:49:00 +1100
commit8875c2cfcd54f1b3d3b436b81f1ba05928d69681 (patch)
tree565605e90927378e9c4d4ca6564fd8d6948293ae
parent8db6dbb4986ea705a5263b810c6cc3b2b75b4986 (diff)
warn if no .md file extension
-rwxr-xr-xmd.sh9
1 files changed, 7 insertions, 2 deletions
diff --git a/md.sh b/md.sh
index d197c13..aa80483 100755
--- a/md.sh
+++ b/md.sh
@@ -4,11 +4,13 @@
#
# stolen from https://unix.stackexchange.com/questions/24931/how-to-make-firefox-read-stdin/24942
+# Check that we have a file to read
if [ $# -ne 1 ]; then
echo "Requires the name of one markdown file"
exit 1
fi
+# check dependencies
if ! command -v marked &> /dev/null; then
echo "Install 'marked' before running this script"
exit 1
@@ -18,8 +20,11 @@ if ! command -v firefox &> /dev/null; then
exit 1
fi
-
-echo there were $# arguments
mdFile=$1
+
+if [ ${mdFile: -3} != ".md" ]; then
+ echo "Works best with a markdown input file, but we'll try to parse it anyway"
+fi
+
marked ${mdFile} | firefox "data:text/html;base64,$(base64 -w 0 <&0)"