summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2023-04-18 11:46:44 +0100
committerdavidovski <david@davidovski.xyz>2023-04-18 11:46:44 +0100
commitaf75a700c52aaca66ffe6db42c4448c2070be21a (patch)
treebd3d493c02293a94953918d1516c6f5b8a6fc6a3
parente4c9a5a027ececc1e72744287be7e3654e31289e (diff)
make md2html accept arguments
-rwxr-xr-xsrc/md2html.sh10
-rw-r--r--src/shblg23
2 files changed, 28 insertions, 5 deletions
diff --git a/src/md2html.sh b/src/md2html.sh
index 47a15d6..590cdaa 100755
--- a/src/md2html.sh
+++ b/src/md2html.sh
@@ -2,6 +2,10 @@
ESC_SEQ='\0'
+cat () {
+ while IFS= read -r line; do printf "%s\n" "$line"; done < "$1"
+}
+
# remove traling whitespace from empty lines
#
_pre_strip () {
@@ -135,7 +139,6 @@ _p () {
empty=false ;;
esac
-
done
$empty || {
@@ -393,7 +396,6 @@ _squash () {
# convert the markdown from stdin into html
#
md2html () {
- # the order of these somewhat matters
_pre_strip \
| _code \
| _pre_emph \
@@ -416,4 +418,6 @@ md2html () {
| _html
}
-md2html
+[ -z "$*" ] \
+ && md2html \
+ || cat $1 | md2html
diff --git a/src/shblg b/src/shblg
index 5361975..ff10250 100644
--- a/src/shblg
+++ b/src/shblg
@@ -1,4 +1,23 @@
#!/bin/sh
-BLOG_DIR
-OUTPUT_DIR
+INPUT_DIR=blog
+OUTPUT_DIR=dist
+PAGE_TEMPLATE=blog/template.html
+
+while getopts ":o:i:t:" opt; do
+ case "$opt" in
+ o)
+ OUTPUT_DIR=$(realpath $OPTARG)
+ ;;
+ i)
+ INPUT_DIR=$(realpath $OPTARG)
+ ;;
+ t)
+ PAGE_TEMPLATE=$(realpath $OPTARG)
+ ;;
+ esac
+done
+
+for f in ${INPUT_DIR}/*.md; do
+ md2html "$f" > ${OUTPUT_DIR}/$f
+done