Browse Source

Markdown.pl: blocks bonanza

During initial processing, explict "block" tags are set aside to
avoid creating problems in the output later.

Adjust the matches to be case insensitive.

Also relax the extra-blank line before and after that only
prevents them being recognized where they need to be.

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

16
Markdown.pl

@ -726,8 +726,8 @@ sub _StripLinkDefinitions {
my ($block_tags_a, $block_tags_b); my ($block_tags_a, $block_tags_b);
BEGIN { BEGIN {
$block_tags_a = qr/p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del/o; $block_tags_a = qr/p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del/io;
$block_tags_b = qr/p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math/o; $block_tags_b = qr/p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math/io;
} }
sub _HashHTMLBlocks { sub _HashHTMLBlocks {
@ -768,7 +768,7 @@ sub _HashHTMLBlocks {
my $key = block_id($1); my $key = block_id($1);
$g_html_blocks{$key} = $1; $g_html_blocks{$key} = $1;
"\n\n" . $key . "\n\n"; "\n\n" . $key . "\n\n";
}egmx; }eigmx;
# #
@ -789,14 +789,14 @@ sub _HashHTMLBlocks {
my $key = block_id($1); my $key = block_id($1);
$g_html_blocks{$key} = $1; $g_html_blocks{$key} = $1;
"\n\n" . $key . "\n\n"; "\n\n" . $key . "\n\n";
}egmx; }eigmx;
# Special case just for <hr />. It was easier to make a special case than # Special case just for <hr />. It was easier to make a special case than
# to make the other regex more complicated. # to make the other regex more complicated.
$text =~ s{ $text =~ s{
(?: (?:
(?<=\n\n) # Starting after a blank line (?<=\n) # Starting after end of line
| # or | # or
\A\n? # the beginning of the doc \A # the beginning of the doc
) )
( # save in $1 ( # save in $1
[ ]{0,$less_than_indent} [ ]{0,$less_than_indent}
@ -805,13 +805,13 @@ sub _HashHTMLBlocks {
(?:[^<>])*? # (?:[^<>])*? #
/?> # the matching end tag /?> # the matching end tag
[ ]* [ ]*
(?=\n{2,}|\Z) # followed by a blank line or end of document (?=\n{1,}|\Z) # followed by end of line or end of document
) )
}{ }{
my $key = block_id($1); my $key = block_id($1);
$g_html_blocks{$key} = $1; $g_html_blocks{$key} = $1;
"\n\n" . $key . "\n\n"; "\n\n" . $key . "\n\n";
}egx; }eigx;
# Special case for standalone HTML comments: # Special case for standalone HTML comments:
$text =~ s{ $text =~ s{

Loading…
Cancel
Save