mirror of http://git.davidovski.xyz/shblg.git
make md2html accept arguments
This commit is contained in:
parent
e4c9a5a027
commit
af75a700c5
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
ESC_SEQ='\0'
|
ESC_SEQ='\0'
|
||||||
|
|
||||||
|
cat () {
|
||||||
|
while IFS= read -r line; do printf "%s\n" "$line"; done < "$1"
|
||||||
|
}
|
||||||
|
|
||||||
# remove traling whitespace from empty lines
|
# remove traling whitespace from empty lines
|
||||||
#
|
#
|
||||||
_pre_strip () {
|
_pre_strip () {
|
||||||
|
@ -135,7 +139,6 @@ _p () {
|
||||||
|
|
||||||
empty=false ;;
|
empty=false ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
$empty || {
|
$empty || {
|
||||||
|
@ -393,7 +396,6 @@ _squash () {
|
||||||
# convert the markdown from stdin into html
|
# convert the markdown from stdin into html
|
||||||
#
|
#
|
||||||
md2html () {
|
md2html () {
|
||||||
# the order of these somewhat matters
|
|
||||||
_pre_strip \
|
_pre_strip \
|
||||||
| _code \
|
| _code \
|
||||||
| _pre_emph \
|
| _pre_emph \
|
||||||
|
@ -416,4 +418,6 @@ md2html () {
|
||||||
| _html
|
| _html
|
||||||
}
|
}
|
||||||
|
|
||||||
md2html
|
[ -z "$*" ] \
|
||||||
|
&& md2html \
|
||||||
|
|| cat $1 | md2html
|
||||||
|
|
23
src/shblg
23
src/shblg
|
@ -1,4 +1,23 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
BLOG_DIR
|
INPUT_DIR=blog
|
||||||
OUTPUT_DIR
|
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
|
||||||
|
|
Loading…
Reference in New Issue