r103990 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103989‎ | r103990 | r103991 >
Date:00:30, 23 November 2011
Author:brion
Status:ok
Tags:
Comment:
Revert r103795 -- adds <dws> pseudotag which modifies preprocessor behavior in some way to eat whitespace

Not sure whether this is something we want, but it should probably be talked over first.
Modified paths:
  • /trunk/phase3/includes/parser/Preprocessor_DOM.php (modified) (history)
  • /trunk/phase3/includes/parser/Preprocessor_Hash.php (modified) (history)
  • /trunk/phase3/tests/parser/parserTests.txt (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/parser/parserTests.txt
@@ -8973,97 +8973,6 @@
89748974 </p>
89758975 !! end
89768976
8977 -!! test
8978 -Bug 31865: HTML-style tag <dws> is recognized and discarded.
8979 -!! input
8980 -one<dws>two
8981 -!! result
8982 -<p>onetwo
8983 -</p>
8984 -!! end
8985 -
8986 -!! test
8987 -Bug 31865: XML-style tag <dws/> is recognized and discarded.
8988 -!! input
8989 -one<dws/>two
8990 -!! result
8991 -<p>onetwo
8992 -</p>
8993 -!! end
8994 -
8995 -!! test
8996 -Bug 31865: Spaces after <dws> tag are discarded.
8997 -!! input
8998 -one<dws> two
8999 -!! result
9000 -<p>onetwo
9001 -</p>
9002 -!! end
9003 -
9004 -!! test
9005 -Bug 31865: Tabs after <dws> tag are discarded too.
9006 -!! input
9007 -one<dws> two
9008 -!! result
9009 -<p>onetwo
9010 -</p>
9011 -!! end
9012 -
9013 -!! test
9014 -Bug 31865: Newlines after <dws> tag are discarded too.
9015 -!! input
9016 -one<dws>
9017 -
9018 -
9019 -two
9020 -!! result
9021 -<p>onetwo
9022 -</p>
9023 -!! end
9024 -
9025 -!! test
9026 -Bug 31865: Spaces before <dws> tag are not discarded.
9027 -!! input
9028 -one <dws>two
9029 -!! result
9030 -<p>one two
9031 -</p>
9032 -!! end
9033 -
9034 -!! test
9035 -Bug 31865: <dws> Continuation is indented.
9036 -!! input
9037 -one<dws>
9038 - two
9039 -!! result
9040 -<p>onetwo
9041 -</p>
9042 -!! end
9043 -
9044 -!! test
9045 -Bug 31865: <dws> List item continuation.
9046 -!! input
9047 -* one<dws>
9048 - two
9049 -* three
9050 -!! result
9051 -<ul><li> onetwo
9052 -</li><li> three
9053 -</li></ul>
9054 -
9055 -!! end
9056 -
9057 -!! test
9058 -Bug 31865: <dws/> XML-style; asterisk after the tag does not start list item.
9059 -!! input
9060 -* one <dws/>
9061 -* two
9062 -!! result
9063 -<ul><li> one * two
9064 -</li></ul>
9065 -
9066 -!! end
9067 -
90688977 TODO:
90698978 more images
90708979 more tables
Index: trunk/phase3/includes/parser/Preprocessor_Hash.php
@@ -153,9 +153,6 @@
154154 $ignoredElements = array( 'includeonly' );
155155 $xmlishElements[] = 'includeonly';
156156 }
157 - // `dws' stands for "discard white spaces". `<dws>' and all the whitespaces afer it are
158 - // discarded.
159 - $xmlishElements[] = 'dws';
160157 $xmlishRegex = implode( '|', array_merge( $xmlishElements, $ignoredTags ) );
161158
162159 // Use "A" modifier (anchored) instead of "^", because ^ doesn't work with an offset
@@ -353,17 +350,6 @@
354351 }
355352
356353 $tagStartPos = $i;
357 -
358 - // Handle tag dws.
359 - if ( $name == 'dws' ) {
360 - $i = $tagEndPos + 1;
361 - if ( preg_match( '/\s*/', $text, $matches, 0, $i ) ) {
362 - $i += strlen( $matches[0] );
363 - }
364 - $accum->addNodeWithText( 'ignore', substr( $text, $tagStartPos, $i - $tagStartPos ) );
365 - continue;
366 - }
367 -
368354 if ( $text[$tagEndPos-1] == '/' ) {
369355 // Short end tag
370356 $attrEnd = $tagEndPos - 1;
Index: trunk/phase3/includes/parser/Preprocessor_DOM.php
@@ -211,9 +211,6 @@
212212 $ignoredElements = array( 'includeonly' );
213213 $xmlishElements[] = 'includeonly';
214214 }
215 - // `dws' stands for "discard white spaces". `<dws>' and all the whitespaces afer it are
216 - // discarded.
217 - $xmlishElements[] = 'dws';
218215 $xmlishRegex = implode( '|', array_merge( $xmlishElements, $ignoredTags ) );
219216
220217 // Use "A" modifier (anchored) instead of "^", because ^ doesn't work with an offset
@@ -409,20 +406,6 @@
410407 }
411408
412409 $tagStartPos = $i;
413 -
414 - // Handle tag `dws'.
415 - if ( $name == 'dws' ) {
416 - $i = $tagEndPos + 1;
417 - if ( preg_match( '/\s*/', $text, $matches, 0, $i ) ) {
418 - $i += strlen( $matches[0] );
419 - }
420 - $accum .=
421 - '<ignore>' .
422 - htmlspecialchars( substr( $text, $tagStartPos, $i - $tagStartPos ) ) .
423 - '</ignore>';
424 - continue;
425 - }
426 -
427410 if ( $text[$tagEndPos-1] == '/' ) {
428411 $attrEnd = $tagEndPos - 1;
429412 $inner = null;

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r103795Fixes Bug 31865 - Tag <dws> for discarding whitespaces....mah01:45, 21 November 2011

Status & tagging log