r19701 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r19700‎ | r19701 | r19702 >
Date:16:31, 31 January 2007
Author:sanbeg
Status:old
Tags:
Comment:
Removed some weirdness from heading regex that caused empty section to be miscounted
Modified paths:
  • /trunk/extensions/LabeledSectionTransclusion/lst.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LabeledSectionTransclusion/lst.php
@@ -33,7 +33,7 @@
3434
3535 function wfLabeledSectionTransclusion()
3636 {
37 - global $wgParser;
 37+ global $wgParser, $wgVersion, $wgHooks;
3838
3939 $wgParser->setHook( 'section', 'wfLstNoop' );
4040 $wgParser->setFunctionHook( 'lst', 'wfLstInclude' );
@@ -83,18 +83,13 @@
8484 **/
8585 function wfLst_parse_($parser, $title, $text, $part1, $skiphead=0)
8686 {
87 - global $wgVersion;
88 -
8987 // if someone tries something like<section begin=blah>lst only</section>
9088 // text, may as well do the right thing.
9189 $text = str_replace('</section>', '', $text);
9290
9391 if (wfLst_open_($parser, $part1)) {
94 -
95 - //Handle recursion here, so we can break cycles. Although we can't do
96 - //feature detection here, r18473 was only a few weeks before the
97 - //release, so this is close enough.
98 -
 92+ //Handle recursion here, so we can break cycles.
 93+ global $wgVersion;
9994 if( version_compare( $wgVersion, "1.9" ) < 0 ) {
10095 $text = $parser->replaceVariables($text);
10196 wfLst_close_($parser, $part1);
@@ -138,7 +133,7 @@
139134 {
140135 //count skipped headings, so parser (as of r18218) can skip them, to
141136 //prevent wrong heading links (see bug 6563).
142 - $pat = '^(={1,6}).+\s*.*?\1\s*$';
 137+ $pat = '^(={1,6}).+\1\s*$';
143138 return preg_match_all( "/$pat/im", substr($text,0,$limit), $m);
144139 }
145140