From 61045141d11e5e7b392ee0c6f57a6c0e1424be4d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Thu, 24 Mar 2022 12:48:14 +0100 Subject: [PATCH] Squashed 'cgilite/' changes from 6fe824f..b2b268b b2b268b corrected paragraph splitting and hr/h2 distinction 33cd660 faster hexdecode for mixed data (e.g. post-data) git-subtree-dir: cgilite git-subtree-split: b2b268b458208ba7746052e05f1f1f5ced081023 --- cgilite.sh | 3 ++- markdown.awk | 11 +++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cgilite.sh b/cgilite.sh index 90d6557..6cbd7ec 100755 --- a/cgilite.sh +++ b/cgilite.sh @@ -89,7 +89,8 @@ HEX_DECODE(){ "$pfx"[0-9a-fA-F][0-9a-fA-F]*) in="${in#${pfx}}";; \\*) in="${in#?}"; out="${out}\\\\"; continue;; %*) in="${in#?}"; out="${out}%%"; continue;; - *) out="${out}${in%"${in#?}"}"; in="${in#?}"; continue;; + *) att="${in%%"${pfx}"*}"; att="${att%%%*}"; att="${att%%\\*}" + out="${out}${att}"; in="${in#"${att}"}"; continue;; esac; # Hex escapes for printf (e.g. \x41) are not portable diff --git a/markdown.awk b/markdown.awk index b3166f9..d28c7cf 100755 --- a/markdown.awk +++ b/markdown.awk @@ -390,6 +390,12 @@ function _block( block, LOCAL, st, len, hlvl, htxt, guard, code, indent, attrib return "" inline( htxt ) "\n\n" \ _block( substr( block, len + 1) ); + # Split paragraphs + } else if ( match( block, /(^|\n)[[:space:]]*(\n|$)/) ) { + len = RLENGTH; st = RSTART; + return _block( substr(block, 1, st - 1) ) "\n" \ + _block( substr(block, st + len) ); + # Horizontal rule } else if ( match( block, /(^|\n) ? ? ?((\* *){3,}|(- *){3,}|(_ *){3,})($|\n)/) ) { len = RLENGTH; st = RSTART; @@ -397,10 +403,7 @@ function _block( block, LOCAL, st, len, hlvl, htxt, guard, code, indent, attrib # Plain paragraph } else { - match( block, /(^|\n)[[:space:]]*(\n|$)/ ) || match( block, /$/ ); - len = RLENGTH; st = RSTART; - return "

" inline( substr(block, 1, st - 1) ) "

\n" \ - _block( substr(block, st + len) ); + return "

" inline(block) "

\n"; } } -- 2.39.2