From 89cae62dd158755e96acc517b2272dd113a19d8a Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Sun, 14 Feb 2021 11:25:18 -0700 Subject: [PATCH] Markdown.pl: do not sequester top-level unmatched p When running _HashHTMLBlocks, there's a step where we "match any empty block tags that should have been paired." Exclude "p" from that list. Given a document like this:

text That isolated "p" was getting sequestered away into its own blob resulting in an output document like this:

text

By removing "p" from the list of "empty block tags that should have been paired," we get this output instead:

text

A nice improvement. Signed-off-by: Kyle J. McKay --- Markdown.pl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Markdown.pl b/Markdown.pl index f5a9a10..63eff11 100755 --- a/Markdown.pl +++ b/Markdown.pl @@ -1205,10 +1205,11 @@ sub _StripLinkDefinitions { } my %ok_tag_name; # initialized later -my ($block_tags_a, $block_tags_b); +my ($block_tags_a, $block_tags_b, $block_tags_c); BEGIN { $block_tags_a = qr/\020|p|div|center|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del/io; $block_tags_b = qr/\020|p|div|center|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math/io; + $block_tags_c = qr/div|center|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math/io; } sub _HashHTMLBlocks { @@ -1284,7 +1285,7 @@ sub _HashHTMLBlocks { ( # save in $1 ^ # start of line (with /m) (?:\Q$idt\E)? # optional lead in - <(?:$block_tags_b) # start tag = $2 + <($block_tags_c) # start tag = $2 \b # word break (?:[^<>])*? # /?> # the matching end tag