diff --git a/Markdown.pl b/Markdown.pl index 2a5a82d..0625440 100755 --- a/Markdown.pl +++ b/Markdown.pl @@ -363,11 +363,11 @@ sub Markdown { # Convert all tabs to spaces. $text = _Detab($text); - # Strip any lines consisting only of spaces and tabs. + # Strip any lines consisting only of spaces. # This makes subsequent regexen easier to write, because we can # match consecutive blank lines with /\n+/ instead of something - # contorted like /[ \t]*\n+/ . - $text =~ s/^[ \t]+$//mg; + # contorted like / *\n+/ . + $text =~ s/^ +$//mg; # Turn block-level HTML blocks into hash entries $text = _HashHTMLBlocks($text); @@ -431,19 +431,19 @@ sub _StripLinkDefinitions { # Link defs are in the form: ^[id]: url "optional title" while ($text =~ s{ ^[ ]{0,$less_than_indent}\[(.+)\]: # id = $1 - [ \t]* + [ ]* \n? # maybe *one* newline - [ \t]* + [ ]* (\S+?)>? # url = $2 - [ \t]* + [ ]* \n? # maybe one newline - [ \t]* + [ ]* (?: (?<=\s) # lookbehind for whitespace ["(] (.+?) # title = $3 [")] - [ \t]* + [ ]* )? # title is optional (?:\n+|\Z) } @@ -493,7 +493,7 @@ sub _HashHTMLBlocks { \b # word break (.*\n)*? # any number of lines, minimally matching \2> # the matching end tag - [ \t]* # trailing spaces/tabs + [ ]* # trailing spaces (?=\n+|\Z) # followed by a newline or end of document ) }{ @@ -513,7 +513,7 @@ sub _HashHTMLBlocks { \b # word break (.*\n)*? # any number of lines, minimally matching .*\2> # the matching end tag - [ \t]* # trailing spaces/tabs + [ ]* # trailing spaces (?=\n+|\Z) # followed by a newline or end of document ) }{ @@ -535,7 +535,7 @@ sub _HashHTMLBlocks { \b # word break ([^<>])*? # /?> # the matching end tag - [ \t]* + [ ]* (?=\n{2,}|\Z) # followed by a blank line or end of document ) }{ @@ -558,7 +558,7 @@ sub _HashHTMLBlocks { (--.*?--\s*)+ > ) - [ \t]* + [ ]* (?=\n{2,}|\Z) # followed by a blank line or end of document ) }{ @@ -582,9 +582,9 @@ sub _RunBlockGamut { $text = _DoHeaders($text, $anchors); # Do Horizontal Rules: - $text =~ s{^ {0,3}\*(?: {0,2}\*){2,}[ \t]*$}{\n
$c
";
@egsx;
@@ -1264,7 +1263,7 @@ sub _DoBlockQuotes {
$text =~ s{
( # Wrap whole match in $1
(
- ^[ \t]*>[ \t]? # '>' at the start of a line
+ ^[ ]*>[ ]? # '>' at the start of a line
.+\n # rest of the first line
(.+\n)* # subsequent consecutive lines
\n* # blanks
@@ -1272,8 +1271,8 @@ sub _DoBlockQuotes {
)
}{
my $bq = $1;
- $bq =~ s/^[ \t]*>[ \t]?//gm; # trim one level of quoting
- $bq =~ s/^[ \t]+$//mg; # trim whitespace-only lines
+ $bq =~ s/^[ ]*>[ ]?//gm; # trim one level of quoting
+ $bq =~ s/^[ ]+$//mg; # trim whitespace-only lines
$bq = _RunBlockGamut($bq); # recurse
$bq =~ s/^/ /mg;
@@ -1304,7 +1303,7 @@ sub _FormParagraphs {
foreach (@grafs) {
unless (defined($g_html_blocks{$_}) || defined($g_code_blocks{$_})) {
$_ = _RunSpanGamut($_);
- s/^([ \t]*)//; + s/^([ ]*)/
/; $_ .= "
"; } }