From 2bd2e05538f77a1a82f5c2552da5eb4bce092c59 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 25 Aug 2024 23:33:04 +0300 Subject: remove deprecated html variant (the prev default one) and bump major gemtexter version --- lib/html.source.sh | 106 ++++++++++++++++++++--------------------------------- 1 file changed, 40 insertions(+), 66 deletions(-) (limited to 'lib/html.source.sh') diff --git a/lib/html.source.sh b/lib/html.source.sh index 540762d..832bada 100644 --- a/lib/html.source.sh +++ b/lib/html.source.sh @@ -12,14 +12,10 @@ html::encode () { html::make_paragraph () { local -r text="$1"; shift - if [ "$HTML_VARIANT_TO_USE" = exact ]; then - if [ -n "$text" ]; then - echo "$(html::encode "$text")
" - else - echo '
' - fi - elif [ -n "$text" ]; then - echo "

$(html::encode "$text")

" + if [ -n "$text" ]; then + echo "$(html::encode "$text")
" + else + echo '
' fi } @@ -29,21 +25,13 @@ html::make_heading () { local -r level="$1"; shift local -r id="$(generate::internal_link_id "$text")" - if [ "$HTML_VARIANT_TO_USE" = exact ]; then - echo "$(html::encode "$text")
" - else - echo "$(html::encode "$text")
" - fi + echo "$(html::encode "$text")
" } # Make a HTML quotation html::make_quote () { local -r quote="${1/> }" - if [ "$HTML_VARIANT_TO_USE" = exact ]; then - echo "$(html::encode "$quote")
" - else - echo "

$(html::encode "$quote")

" - fi + echo "$(html::encode "$quote")
" } # Make a HTML image @@ -177,11 +165,7 @@ html::fromgmi () { echo "
  • $(html::list::encode "${line/\* /}")
  • " | html::process_inline else is_list=no - if [ "$HTML_VARIANT_TO_USE" = exact ]; then - echo "
    " - else - echo "" - fi + echo "
    " fi continue @@ -232,24 +216,49 @@ $line" done } -# Test default HTML variant. -html::test::default () { +html::test () { + local line='Hello world! This is a paragraph.' + assert::equals "$(html::make_paragraph "$line")" "Hello world! This is a paragraph.
    " + + line='' + assert::equals "$(html::make_paragraph "$line")" '
    ' + + line='Foo &<>& Bar!' + assert::equals "$(html::make_paragraph "$line")" "Foo &<>& Bar!
    " + + line='echo foo 2>&1' + assert::equals "$(html::make_paragraph "$line")" "echo foo 2>&1
    " + + line='# Header 1' + local id='header-1' + assert::equals "$(html::make_heading "$line" 1)" "

    Header 1


    " + + line='## Header 2' + id='header-2' + assert::equals "$(html::make_heading "$line" 2)" "

    Header 2


    " + + line='### Header 3' + id='header-3' + assert::equals "$(html::make_heading "$line" 3)" "

    Header 3


    " + + line='> This is a quote' + assert::equals "$(html::make_quote "$line")" "This is a quote
    " MASTODON_URI='' - local line='Hello world! This is a paragraph.' - assert::equals "$(html::make_paragraph "$line")" '

    Hello world! This is a paragraph.

    ' + line='Hello world! This is a paragraph.' + assert::equals "$(html::make_paragraph "$line")" 'Hello world! This is a paragraph.
    ' line='' - assert::equals "$(html::make_paragraph "$line")" '' + assert::equals "$(html::make_paragraph "$line")" '
    ' line='Foo &<>& Bar!' - assert::equals "$(html::make_paragraph "$line")" '

    Foo &<>& Bar!

    ' + assert::equals "$(html::make_paragraph "$line")" 'Foo &<>& Bar!
    ' line='echo foo 2>&1' - assert::equals "$(html::make_paragraph "$line")" '

    echo foo 2>&1

    ' + assert::equals "$(html::make_paragraph "$line")" 'echo foo 2>&1
    ' line='> This is a quote' - assert::equals "$(html::make_quote "$line")" "

    This is a quote

    " + assert::equals "$(html::make_quote "$line")" "This is a quote
    " line='Testing: `hello_world.sh --debug` :-) `another one`!' assert::equals "$(echo "$line" | html::process_inline)" \ @@ -312,38 +321,3 @@ fi assert::contains "$(html::fromgmi <<< "$input_block")" 'GNU source-highlight' fi } - -# Test exact HTML variant. -html::test::exact () { - local line='Hello world! This is a paragraph.' - assert::equals "$(html::make_paragraph "$line")" "Hello world! This is a paragraph.
    " - - line='' - assert::equals "$(html::make_paragraph "$line")" '
    ' - - line='Foo &<>& Bar!' - assert::equals "$(html::make_paragraph "$line")" "Foo &<>& Bar!
    " - - line='echo foo 2>&1' - assert::equals "$(html::make_paragraph "$line")" "echo foo 2>&1
    " - - line='# Header 1' - local id='header-1' - assert::equals "$(html::make_heading "$line" 1)" "

    Header 1


    " - - line='## Header 2' - id='header-2' - assert::equals "$(html::make_heading "$line" 2)" "

    Header 2


    " - - line='### Header 3' - id='header-3' - assert::equals "$(html::make_heading "$line" 3)" "

    Header 3


    " - - line='> This is a quote' - assert::equals "$(html::make_quote "$line")" "This is a quote
    " -} - -html::test () { - HTML_VARIANT_TO_USE=default html::test::default - HTML_VARIANT_TO_USE=exact html::test::exact -} -- cgit v1.2.3