From f8b8b0a7cad96c648c896fa6eb660fdb988dfdb2 Mon Sep 17 00:00:00 2001 From: davidovski Date: Sun, 31 Dec 2023 01:25:56 +0000 Subject: reformat --- src/md2html.sh | 56 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'src/md2html.sh') diff --git a/src/md2html.sh b/src/md2html.sh index 54ed1fe..e249ee0 100755 --- a/src/md2html.sh +++ b/src/md2html.sh @@ -25,7 +25,6 @@ _pre_strip () { while IFS= read -r line; do set -- $line [ "$*" ] && { - local l c l="$line" line= while [ "$l" != "${l#?}" ]; do @@ -63,7 +62,7 @@ _post_emph () { case "$line" in "$ESC_SEQ"*) printf "%s\n" "$line" && continue;; esac # TODO: avoid this problem entirely? - local wrong="" right="" + wrong="" right="" while [ "$line" != "${line%%${wrong}*}" ]; do printf "%s${right}" "${line%%${wrong}*}" @@ -78,8 +77,9 @@ _post_emph () { # emph [bound] # _emph () { - local bound="$1" - local lefttag="$2" righttag="$3" + bound="$1" + lefttag="$2" + righttag="$3" while IFS= read -r line; do case "$line" in "$ESC_SEQ"*) printf "%s\n" "$line" && continue;; esac @@ -103,7 +103,7 @@ _emph () { # h [heading no.] # _h () { - local num=$1 + num=$1 while IFS= read -r line; do case "$line" in "$ESC_SEQ"*) printf "%s\n" "$line" && continue;; esac s= @@ -128,7 +128,7 @@ _h () { # parse paragraphs # _p () { - local empty=true + empty=true while IFS= read -r line; do case "$line" in "$ESC_SEQ"*) printf "%s\n" "$line" && continue;; @@ -139,13 +139,13 @@ _p () { } printf "%s\n" "$line" ;; - "") + "") $empty || { printf "

\n" - empty=true + empty=true } ;; - *) + *) $empty && printf "

\n%s\n" "$line" || printf "%s\n" "$line" @@ -167,9 +167,9 @@ _p () { # parse links # _a_img () { - local open="[" mid="](" close=")" + open="[" mid="](" close=")" while IFS= read -r line; do - case "$line" in "$ESC_SEQ"*) printf "%s\n" "$line" && continue;; esac + case "$line" in "$ESC_SEQ"*) printf "%s\n" "$line" && continue; esac next="$line" while [ "$next" != "${next#*$close}" ]; do case "$next" in @@ -187,7 +187,7 @@ _a_img () { || title= case "$before" in - *!) h="%s\n%s\"%s\"\n" + *!) h="%s\n%s\"%s\"\n" before="${before%!}" ;; *) h="%s\n%s\n%s\n" ;; esac @@ -211,12 +211,12 @@ _get_indent () { " ") indent=$((indent+1)) ;; *) l="${l#?}" - break + break ;; esac l="${l#?}" done - printf "$indent" + printf "%s" "$indent" } # print a string x times @@ -225,7 +225,7 @@ _get_indent () { print_x () { x=$1; shift until [ "$((x=x-1))" -lt "0" ]; do - printf "$*" + printf "%s" "$*" done } @@ -233,8 +233,8 @@ print_x () { # parse unordered lists # _ul () { - local indent_level=-1 - local to_close=0 + indent_level=-1 + to_close=0 while IFS= read -r line; do case "$line" in "$ESC_SEQ"*) printf "%s\n" "$line" && continue;; esac set -- $line @@ -254,7 +254,7 @@ _ul () { printf "

  • %s
  • \n" "${line#*$1 }" ;; - *) + *) [ $to_close -gt 0 ] && { print_x $to_close "\n" to_close=0 @@ -270,12 +270,12 @@ _ul () { # parse ordered lists # _ol () { - local indent_level=-1 - local to_close=0 + indent_level=-1 + to_close=0 while IFS= read -r line; do case "$line" in "$ESC_SEQ"*) printf "%s\n" "$line" && continue;; esac set -- $line - case "$1" in + case "$1" in *.|*\)) indent=$(_get_indent "$line") @@ -284,14 +284,14 @@ _ol () { to_close=$((to_close+1)) } [ "$indent_level" -gt "$indent" ] && { - printf "\n" + printf "\n" to_close=$((to_close-1)) } indent_level=$indent printf "
  • %s
  • \n" "${line#*$1 }" ;; - *) + *) [ $to_close -gt 0 ] && { print_x $to_close "\n" to_close=0 @@ -315,7 +315,7 @@ $ESC_SEQ" " # parse multiline codeblocks # _code () { - local codeblock=false content=true + codeblock=false content=true while IFS= read -r line; do case "$line" in " "*) @@ -351,7 +351,7 @@ _code () { # parse quotes # _blockquote () { - local indent_level=0 + indent_level=0 while IFS= read -r line; do case "$line" in "$ESC_SEQ"*) printf "%s\n" "$line" && continue;; esac set - $line @@ -389,8 +389,8 @@ _html () { done } -# remove all unecessary newlines -# +# remove all unecessary newlines +# _squash () { while IFS= read -r line; do case "$line" in @@ -433,4 +433,4 @@ md2html () { [ -z "$*" ] \ && md2html \ - || cat "$1" | md2html + || md2html < "$1" -- cgit v1.2.1