diff --git a/src/md2html.sh b/src/md2html.sh index 7387fb2..86ebc3d 100755 --- a/src/md2html.sh +++ b/src/md2html.sh @@ -110,8 +110,8 @@ _p () { # parse ref-style links # -_ref () { -} +#_ref () { +#} # parse links # @@ -144,25 +144,106 @@ _a_img () { done } + +_get_indent () { + indent=0 + l="$*" + while [ "$l" ]; do + c="${l%*${l#?}}" + case "$c" in + " ") indent=$((indent+1)) ;; + *) + l="${l#?}" + break + ;; + esac + l="${l#?}" + done + printf "$indent" +} + + # parse unordered lists # _ul () { + local list=false + local indent_level=0 + while IFS= read -r line; do + set -- $line + case "$1" in + "-"|"_"|"+") + indent=$(_get_indent "$line") + + $list || { + list=true + printf "
" "
" \
diff --git a/src/test.md b/src/test.md
index 6aacbed..d527b96 100644
--- a/src/test.md
+++ b/src/test.md
@@ -9,3 +9,22 @@ click [here](http) for stuff and [over here](http12 "my title") for more
this is a paragraph
haha
+
+- this is a list
+ - of items
+ - please dont
+- break
+
+
+* star list
+* this is a star
+
++ plus now wow
++ plus wow so cool
+
+1. hello
+2. world
+3. lOL
+
+
+ok that worked?