From 27ed46c9129db86669052d4e7211340da1081d89 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 19 May 2021 12:39:49 +0100 Subject: html branch --- packages/html.source.sh | 153 ------------------------------------------------ 1 file changed, 153 deletions(-) delete mode 100644 packages/html.source.sh (limited to 'packages/html.source.sh') diff --git a/packages/html.source.sh b/packages/html.source.sh deleted file mode 100644 index 5a292f1c..00000000 --- a/packages/html.source.sh +++ /dev/null @@ -1,153 +0,0 @@ -# Convert special characters to their HTML codes -html::encode () { - $SED ' - s|\&|\&|g; - s|<|\<|g; - s|>|\>|g; - ' <<< "$@" -} - -# Make a HTML paragraph. -html::make_paragraph () { - local -r text="$1"; shift - test -n "$text" && echo "

$(html::encode "$text")

" -} - -# Make a HTML header. -html::make_heading () { - local -r text=$($SED -E 's/^#+ //' <<< "$1"); shift - local -r level="$1"; shift - echo "$(html::encode "$text")" -} - -# Make a HTML quotation -html::make_quote () { - local -r quote="${1/> }" - echo "

$(html::encode "$quote")

" -} - -# Make a HTML image -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 "
" -} - -# Make a HTML hyperlink -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
" -} - -# Convert Gemtext to HTML -html::fromgmi () { - local is_list=no - local is_plain=no - - while IFS='' read -r line; do - if [[ "$is_list" == yes ]]; then - if [[ "$line" == '* '* ]]; then - echo "
  • $(html::encode "${line/\* /}")
  • " - else - is_list=no - echo "" - fi - continue - - elif [[ "$is_plain" == yes ]]; then - if [[ "$line" == '```'* ]]; then - echo "" - is_plain=no - else - html::encode "$line" - fi - continue - fi - - case "$line" in - '* '*) - is_list=yes - echo "