Browse Source

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:

  <p>
  text

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

  <p>

  </p><p>text</p>

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

  <p>
  text</p>

A nice improvement.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
master
Kyle J. McKay 3 years ago
parent
commit
89cae62dd1
  1. 5
      Markdown.pl

5
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

Loading…
Cancel
Save