From b2b268b458208ba7746052e05f1f1f5ced081023 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Thu, 24 Mar 2022 12:46:24 +0100 Subject: [PATCH] corrected paragraph splitting and hr/h2 distinction --- markdown.awk | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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