X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fparser%2FParser.php;h=b66031cc8804169f36aed386e585006a781ded2e;hb=5739d1454b5bc5ae7fe178ac7b92dd2134d7f194;hp=e54588750b2c2fe36d9fa34e251289b3a357502b;hpb=305a056dac55de31f00aee05b8c5cd7bfeec88a6;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index e54588750b..b66031cc88 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -1471,7 +1471,7 @@ class Parser { /** * @throws MWException * @param array $m - * @return HTML|string + * @return string HTML */ public function magicLinkCallback( $m ) { if ( isset( $m[1] ) && $m[1] !== '' ) { @@ -1623,7 +1623,9 @@ class Parser { public function doHeadings( $text ) { for ( $i = 6; $i >= 1; --$i ) { $h = str_repeat( '=', $i ); - $text = preg_replace( "/^$h(.+)$h\\s*$/m", "\\1", $text ); + // Trim non-newline whitespace from headings + // Using \s* will break for: "==\n===\n" and parse as

=

+ $text = preg_replace( "/^(?:$h)[ \\t]*(.+?)[ \\t]*(?:$h)\\s*$/m", "\\1", $text ); } return $text; } @@ -4056,10 +4058,11 @@ class Parser { # Get all headlines for numbering them and adding funky stuff like [edit] # links - this is for later, but we need the number of headlines right now - # This regexp also trims whitespace in the heading's content + # NOTE: white space in headings have been trimmed in doHeadings. They shouldn't + # be trimmed here since whitespace in HTML headings is significant. $matches = []; $numMatches = preg_match_all( - '/[1-6])(?P.*?>)\s*(?P
[\s\S]*?)\s*<\/H[1-6] *>/i', + '/[1-6])(?P.*?>)(?P
[\s\S]*?)<\/H[1-6] *>/i', $text, $matches );