From 6b8c029638708155129f71e5f59c7c3adfa149ab Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Wed, 9 Oct 2024 07:12:58 +0200 Subject: [PATCH] Squashed 'cgilite/' changes from 32b4555..290cc67 290cc67 bugfix: avoid endless loops for some incomplete matches git-subtree-dir: cgilite git-subtree-split: 290cc67245726ca72bb8450162cb2adc5a8c78d1 --- markdown.awk | 15 +++++++-------- tests-markdown.sh | 13 +++++++++++-- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/markdown.awk b/markdown.awk index 356a987..bef97d1 100755 --- a/markdown.awk +++ b/markdown.awk @@ -372,11 +372,10 @@ function inline( line, LOCAL, len, text, code, href, guard, ret ) { ret = ret HTML(substr(line, 1, 1)); line = substr(line, 2); continue; - # continue walk over string - } else { - ret = ret substr(line, 1, 1); line = substr(line, 2); - continue; - } + } # inline patterns end + + # continue walk over string + ret = ret substr(line, 1, 1); line = substr(line, 2); } return ret; } @@ -851,10 +850,10 @@ function _block( block, LOCAL, st, len, text, title, attrib, href, guard, code, ret = ret _block(substr(block, 1, st - 1)) "
\n"; block = substr(block, st + len); continue; + } # block patterns end + # Plain paragraph - } else { - return ret "

" inline(block) "

\n"; - } + return ret "

" inline(block) "

\n"; } return ret; } diff --git a/tests-markdown.sh b/tests-markdown.sh index a834391..6df4224 100755 --- a/tests-markdown.sh +++ b/tests-markdown.sh @@ -1,6 +1,6 @@ #!/bin/sh -runtimes="gawk bawk mawk goawk" +runtimes="gawk busybox mawk goawk" BR=' ' @@ -9,7 +9,7 @@ fail() { printf '%s\n' "$@"; exit 1; } awk() { /bin/awk "$@"; } md_gawk() { gawk -f markdown.awk "$@"; } -md_bawk() { busybox awk -f markdown.awk "$@"; } +md_busybox() { busybox awk -f markdown.awk "$@"; } md_mawk() { mawk -f markdown.awk "$@"; } md_goawk() { goawk -f markdown.awk "$@"; } @@ -45,6 +45,7 @@ assert '~sub~' '

sub

' "subscript" assert "foo ${BR}bar" "

foo
${BR}bar

" 'double space line break' assert '```©```' "

©

" "code span escape" +assert '````' "
````
" "empty code span" assert '_emphasized text_' '

emphasized text

' "em" assert '_emphasized_text_' '

emphasized_text

' "em" @@ -190,6 +191,14 @@ not be but &shy; <escaped>' \ "fenced code block" +assert 'foobar +```` +foobar' \ +'

foobar +```` +foobar

' \ +"Open Fence" + # Block Images assert '![Testbild](Test Bild.jpg)' \ '
Testbild
' \ -- 2.39.2