From 1eac038e141dddb40f6b151ae75c72c3bdc8deba Mon Sep 17 00:00:00 2001
From: davidovki
%s " "$line" || - printf "%s " "$line" + printf "
\n%s\n " "$line" || + printf "%s\n " "$line" empty=false ;; esac @@ -146,7 +149,8 @@ _a_img () { done } - +# get indentation level of a line +# _get_indent () { indent=0 l="$*" @@ -244,15 +248,54 @@ _ol () { # parse quotes # -#_quote () { -#} +_blockquote () { + local level=0 + while IFS= read -r line; do + set - $line + case "$1" in + ">"*) + indent=0 + while [ "$line" ]; do + c="${line%*${line#?}}" + case "$c" in + ">") indent=$((indent+1)) ;; + " "*) + line="${line#?}" + break + ;; + esac + line="${line#?}" + done + + [ "$indent" -gt "$level" ] && + printf "
\n" + [ "$indent" -lt "$level" ] && + printf "\n" + level="$indent" + printf "%s\n" "$line" + ;; + *) + printf "%s\n" "$line" + ;; + esac + done + [ "$indent" -lt "$level" ] && + printf "\n" +} + +_html () { + printf "\n" + cat +} # convert the markdown from stdin into html # md2html () { + # the order of these somewhat matters _pre_emph \ + | _blockquote \ | _ul \ | _ol \ | _p \ @@ -266,7 +309,8 @@ md2html () { | _h 4 \ | _h 3 \ | _h 2 \ - | _h 1 + | _h 1 \ + | _html } md2html diff --git a/src/test.md b/src/test.md index d527b96..39750ac 100644 --- a/src/test.md +++ b/src/test.md @@ -8,6 +8,19 @@ click [here](http) for stuff and [over here](http12 "my title") for more this is a paragraph +> this is a quote hi + +ok that was a quote + +> this quote has a list inside i +> - this is a list in a quote +> - it was quoted +> +> and also there is another quote; +>> Hi i am a quote +> + + haha - this is a list -- cgit v1.2.1