From 1079f927a27db9d194c8e25eb3a188396fdf8eab Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Mon, 17 May 2021 21:02:55 +0100 Subject: refactor code --- modules/html.source.sh | 146 ------------------------------------------------- 1 file changed, 146 deletions(-) delete mode 100644 modules/html.source.sh (limited to 'modules/html.source.sh') diff --git a/modules/html.source.sh b/modules/html.source.sh deleted file mode 100644 index 3eb2ee4e..00000000 --- a/modules/html.source.sh +++ /dev/null @@ -1,146 +0,0 @@ -html::special () { - $SED ' - s|\&|\&|g; - s|<|\<|g; - s|>|\>|g; - ' <<< "$@" -} - -html::make_paragraph () { - local -r text="$1"; shift - test -n "$text" && echo "

$(html::special "$text")

" -} - -html::make_heading () { - local -r text=$($SED -E 's/^#+ //' <<< "$1"); shift - local -r level="$1"; shift - - echo "$(html::special "$text")" -} - -html::make_quote () { - local -r quote="${1/> }" - echo "

$(html::special "$quote")

" -} - -html::make_img () { - local link="$1"; shift - local descr="$1"; shift - - if [ -z "$descr" ]; then - echo -n "" - else - echo -n "$descr:" - echo -n "\"$descr\"" - fi - - echo "
" -} - -html::make_link () { - local link="$1"; shift - local descr="$1"; shift - - grep -F -q '://' <<< "$link" || link=${link/.gmi/.html} - test -z "$descr" && descr="$link" - echo "$descr
" -} - -html::fromgmi () { - local -i is_list=0 - local -i is_plain=0 - - while IFS='' read -r line; do - if [ $is_list -eq 1 ]; then - if [[ "$line" == '* '* ]]; then - echo "
  • $(html::special "${line/\* /}")
  • " - else - is_list=0 - echo "" - fi - continue - - elif [ $is_plain -eq 1 ]; then - if [[ "$line" == '```'* ]]; then - echo "" - is_plain=0 - else - html::special "$line" - fi - continue - fi - - case "$line" in - '* '*) - is_list=1 - echo "