From: Paul Hänsch Date: Thu, 24 Mar 2022 11:46:24 +0000 (+0100) Subject: corrected paragraph splitting and hr/h2 distinction X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=b2b268b458208ba7746052e05f1f1f5ced081023;p=cgilite corrected paragraph splitting and hr/h2 distinction --- 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"; } }