Index: trunk/phase3/tests/parser/parserTests.txt |
— | — | @@ -8930,6 +8930,97 @@ |
8931 | 8931 | </p> |
8932 | 8932 | !! end |
8933 | 8933 | |
| 8934 | +!! test |
| 8935 | +Bug 31865: HTML-style tag <dws> is recognized and discarded. |
| 8936 | +!! input |
| 8937 | +one<dws>two |
| 8938 | +!! result |
| 8939 | +<p>onetwo |
| 8940 | +</p> |
| 8941 | +!! end |
| 8942 | + |
| 8943 | +!! test |
| 8944 | +Bug 31865: XML-style tag <dws/> is recognized and discarded. |
| 8945 | +!! input |
| 8946 | +one<dws/>two |
| 8947 | +!! result |
| 8948 | +<p>onetwo |
| 8949 | +</p> |
| 8950 | +!! end |
| 8951 | + |
| 8952 | +!! test |
| 8953 | +Bug 31865: Spaces after <dws> tag are discarded. |
| 8954 | +!! input |
| 8955 | +one<dws> two |
| 8956 | +!! result |
| 8957 | +<p>onetwo |
| 8958 | +</p> |
| 8959 | +!! end |
| 8960 | + |
| 8961 | +!! test |
| 8962 | +Bug 31865: Tabs after <dws> tag are discarded too. |
| 8963 | +!! input |
| 8964 | +one<dws> two |
| 8965 | +!! result |
| 8966 | +<p>onetwo |
| 8967 | +</p> |
| 8968 | +!! end |
| 8969 | + |
| 8970 | +!! test |
| 8971 | +Bug 31865: Newlines after <dws> tag are discarded too. |
| 8972 | +!! input |
| 8973 | +one<dws> |
| 8974 | + |
| 8975 | + |
| 8976 | +two |
| 8977 | +!! result |
| 8978 | +<p>onetwo |
| 8979 | +</p> |
| 8980 | +!! end |
| 8981 | + |
| 8982 | +!! test |
| 8983 | +Bug 31865: Spaces before <dws> tag are not discarded. |
| 8984 | +!! input |
| 8985 | +one <dws>two |
| 8986 | +!! result |
| 8987 | +<p>one two |
| 8988 | +</p> |
| 8989 | +!! end |
| 8990 | + |
| 8991 | +!! test |
| 8992 | +Bug 31865: <dws> Continuation is indented. |
| 8993 | +!! input |
| 8994 | +one<dws> |
| 8995 | + two |
| 8996 | +!! result |
| 8997 | +<p>onetwo |
| 8998 | +</p> |
| 8999 | +!! end |
| 9000 | + |
| 9001 | +!! test |
| 9002 | +Bug 31865: <dws> List item continuation. |
| 9003 | +!! input |
| 9004 | +* one<dws> |
| 9005 | + two |
| 9006 | +* three |
| 9007 | +!! result |
| 9008 | +<ul><li> onetwo |
| 9009 | +</li><li> three |
| 9010 | +</li></ul> |
| 9011 | + |
| 9012 | +!! end |
| 9013 | + |
| 9014 | +!! test |
| 9015 | +Bug 31865: <dws/> XML-style; asterisk after the tag does not start list item. |
| 9016 | +!! input |
| 9017 | +* one <dws/> |
| 9018 | +* two |
| 9019 | +!! result |
| 9020 | +<ul><li> one * two |
| 9021 | +</li></ul> |
| 9022 | + |
| 9023 | +!! end |
| 9024 | + |
8934 | 9025 | TODO: |
8935 | 9026 | more images |
8936 | 9027 | more tables |
Index: trunk/phase3/includes/parser/Preprocessor_Hash.php |
— | — | @@ -153,6 +153,9 @@ |
154 | 154 | $ignoredElements = array( 'includeonly' ); |
155 | 155 | $xmlishElements[] = 'includeonly'; |
156 | 156 | } |
| 157 | + // `dws' stands for "discard white spaces". `<dws>' and all the whitespaces afer it are |
| 158 | + // discarded. |
| 159 | + $xmlishElements[] = 'dws'; |
157 | 160 | $xmlishRegex = implode( '|', array_merge( $xmlishElements, $ignoredTags ) ); |
158 | 161 | |
159 | 162 | // Use "A" modifier (anchored) instead of "^", because ^ doesn't work with an offset |
— | — | @@ -350,6 +353,17 @@ |
351 | 354 | } |
352 | 355 | |
353 | 356 | $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 | + |
354 | 368 | if ( $text[$tagEndPos-1] == '/' ) { |
355 | 369 | // Short end tag |
356 | 370 | $attrEnd = $tagEndPos - 1; |
Index: trunk/phase3/includes/parser/Preprocessor_DOM.php |
— | — | @@ -211,6 +211,9 @@ |
212 | 212 | $ignoredElements = array( 'includeonly' ); |
213 | 213 | $xmlishElements[] = 'includeonly'; |
214 | 214 | } |
| 215 | + // `dws' stands for "discard white spaces". `<dws>' and all the whitespaces afer it are |
| 216 | + // discarded. |
| 217 | + $xmlishElements[] = 'dws'; |
215 | 218 | $xmlishRegex = implode( '|', array_merge( $xmlishElements, $ignoredTags ) ); |
216 | 219 | |
217 | 220 | // Use "A" modifier (anchored) instead of "^", because ^ doesn't work with an offset |
— | — | @@ -406,6 +409,20 @@ |
407 | 410 | } |
408 | 411 | |
409 | 412 | $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 | + |
410 | 427 | if ( $text[$tagEndPos-1] == '/' ) { |
411 | 428 | $attrEnd = $tagEndPos - 1; |
412 | 429 | $inner = null; |