From 23d5a27e2e5f7c65e2cfbbba21ceb4633d83d704 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Mon, 12 Sep 2011 19:16:22 +0000 Subject: [PATCH] Reverted r86072, r86419 per CR. Lots of conflicts resolved here. Removes lineStart from r87346 code as well for preprocess parser tests. --- includes/parser/Parser.php | 7 +- includes/parser/Preprocessor_DOM.php | 2 +- includes/parser/Preprocessor_Hash.php | 2 +- tests/parser/parserTests.txt | 66 +------------------ .../preprocess/All_system_messages.expected | 2 +- tests/parser/preprocess/Factorial.expected | 2 +- .../includes/parser/PreprocessorTest.php | 55 ++++++++-------- 7 files changed, 37 insertions(+), 99 deletions(-) diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 68356e48ff..b50c5f0a9f 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -857,8 +857,11 @@ class Parser { # empty line, go to next line, # but only append \n if outside of table - if ( $line === '') { - $output .= $outLine . "\n"; + if ( $line === '' ) { + $output .= $outLine; + if ( !isset( $tables[0] ) ) { + $output .= "\n"; + } continue; } $firstChars = $line[0]; diff --git a/includes/parser/Preprocessor_DOM.php b/includes/parser/Preprocessor_DOM.php index e6c1d674ab..128b36a339 100644 --- a/includes/parser/Preprocessor_DOM.php +++ b/includes/parser/Preprocessor_DOM.php @@ -543,7 +543,7 @@ class Preprocessor_DOM implements Preprocessor { 'open' => $curChar, 'close' => $rule['end'], 'count' => $count, - 'lineStart' => ($i == 0 || $text[$i-1] == "\n"), + 'lineStart' => ($i > 0 && $text[$i-1] == "\n"), ); $stack->push( $piece ); diff --git a/includes/parser/Preprocessor_Hash.php b/includes/parser/Preprocessor_Hash.php index 50af6b6b63..509f2d5070 100644 --- a/includes/parser/Preprocessor_Hash.php +++ b/includes/parser/Preprocessor_Hash.php @@ -498,7 +498,7 @@ class Preprocessor_Hash implements Preprocessor { 'open' => $curChar, 'close' => $rule['end'], 'count' => $count, - 'lineStart' => ($i == 0 || $text[$i-1] == "\n"), + 'lineStart' => ($i > 0 && $text[$i-1] == "\n"), ); $stack->push( $piece ); diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index bde769c809..0cc586247a 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -1558,38 +1558,6 @@ Table with list inside !! end -!! test -Table with broken up list inside -!! input -{| -|style="width: 5em; text-align: center"| gives -|style="border: 1px dashed #2F6FAB; padding: 0.5em; margin: 0.5em"| -# Some -# list -# Lorem - -# ipsum -# dolor -|} -!! result - - - - - -
gives - -
  1. Some -
  2. list -
  3. Lorem -
-
  1. ipsum -
  2. dolor -
-
- -!! end - !! test Indented table wrapped in html tags (Related to Bug 26362) !! input @@ -1947,8 +1915,6 @@ Arbitrary whitespace should not be prepended 1 2 -


-

@@ -3570,35 +3536,6 @@ section=1 ==Section 1== !! result ==Section 1== -!! end -!! article -Template:Top-level template -!! text -{{Nested template}} -!! endarticle - -!! article -Template:Nested template -!! text -*Item 1 -*Item 2 -!! endarticle - -!! test -Line-start flag in a nested template call -!! input -*Item A -*Item B - -{{Top-level template}} -!! result - - - !! end ### @@ -6288,7 +6225,6 @@ http://===r:::https://b !!result

http://===r:::https://b -


!! end @@ -6327,7 +6263,7 @@ MOVE YOUR MOUSE CURSOR OVER THIS TEXT

{{{| }}}} >
-

MOVE YOUR MOUSE CURSOR OVER THIS TEXT +MOVE YOUR MOUSE CURSOR OVER THIS TEXT

diff --git a/tests/parser/preprocess/All_system_messages.expected b/tests/parser/preprocess/All_system_messages.expected index 96d4569b62..897c5fb00c 100644 --- a/tests/parser/preprocess/All_system_messages.expected +++ b/tests/parser/preprocess/All_system_messages.expected @@ -1,4 +1,4 @@ - + <table border=1 width=100%><tr><td> '''Name''' diff --git a/tests/parser/preprocess/Factorial.expected b/tests/parser/preprocess/Factorial.expected index 099029c04b..a10fd6cad3 100644 --- a/tests/parser/preprocess/Factorial.expected +++ b/tests/parser/preprocess/Factorial.expected @@ -1,4 +1,4 @@ -1011*011*021*031*041*051*061*071*081*091*101*111*121*131*141*151*161*171*181*191*201*211*221*231*241*251*261*271*281*291*301*311*321*331*341*351*361*371*381*391*401*411*421*431*441*451*461*471*481*491*501*511*521*531*541*551*561*571*581*591*601*611*621*631*641*651*661*671*681*691*701*711*721*731*741*751*761*771*781*791*801*811*821*831*841*851*861*871*881*891*901*911*921*931*941*951*961*971*981*99<noinclude> +1011*011*021*031*041*051*061*071*081*091*101*111*121*131*141*151*161*171*181*191*201*211*221*231*241*251*261*271*281*291*301*311*321*331*341*351*361*371*381*391*401*411*421*431*441*451*461*471*481*491*501*511*521*531*541*551*561*571*581*591*601*611*621*631*641*651*661*671*681*691*701*711*721*731*741*751*761*771*781*791*801*811*821*831*841*851*861*871*881*891*901*911*921*931*941*951*961*971*981*99<noinclude> This template finds the [[factorial]] of a number. To use it, enter:<br /> <code><nowiki></nowiki></code><br /> diff --git a/tests/phpunit/includes/parser/PreprocessorTest.php b/tests/phpunit/includes/parser/PreprocessorTest.php index 7a5948d4ed..b53ea1fae0 100644 --- a/tests/phpunit/includes/parser/PreprocessorTest.php +++ b/tests/phpunit/includes/parser/PreprocessorTest.php @@ -49,43 +49,42 @@ class PreprocessorTest extends MediaWikiTestCase { array( "== Foo ==\n== Bar == \n", "== Foo ==\n== Bar == \n" ), array( "===========", "===========" ), array( "Foo\n=\n==\n=\n", "Foo\n=\n==\n=\n" ), - array( "{{Foo}}", "" ), + array( "{{Foo}}", "" ), array( "\n{{Foo}}", "\n" ), - array( "{{Foo|bar}}", "" ), - array( "{{Foo|bar}}a", "a" ), - array( "{{Foo|bar|baz}}", "" ), - array( "{{Foo|1=bar}}", "" ), - array( "{{Foo|=bar}}", "" ), - array( "{{Foo|bar=baz}}", "" ), - array( "{{Foo|1=bar|baz}}", "" ), - array( "{{Foo|1=bar|2=baz}}", "" ), - array( "{{Foo|bar|foo=baz}}", "" ), - array( "{{{1}}}", "1" ), - array( "{{{1|}}}", "1" ), - array( "{{{Foo}}}", "Foo" ), - array( "{{{Foo|}}}", "Foo" ), - array( "{{{Foo|bar|baz}}}", "Foobarbaz" ), + array( "{{Foo|bar}}", "" ), + array( "{{Foo|bar}}a", "a" ), + array( "{{Foo|bar|baz}}", "" ), + array( "{{Foo|1=bar}}", "" ), + array( "{{Foo|=bar}}", "" ), + array( "{{Foo|bar=baz}}", "" ), + array( "{{Foo|1=bar|baz}}", "" ), + array( "{{Foo|bar|foo=baz}}", "" ), + array( "{{{1}}}", "1" ), + array( "{{{1|}}}", "1" ), + array( "{{{Foo}}}", "Foo" ), + array( "{{{Foo|}}}", "Foo" ), + array( "{{{Foo|bar|baz}}}", "Foobarbaz" ), array( "{{Foo}}", "{<!-- -->{Foo}}" ), array( "{{{{Foobar}}}}", "{Foobar}" ), - array( "{{{ {{Foo}} }}}", " <template><title>Foo " ), - array( "{{ {{{Foo}}} }}", "" ), - array( "{{{{{Foo}}}}}", "" ), - array( "{{{{{Foo}} }}}", "<template><title>Foo " ), - array( "{{{{{{Foo}}}}}}", "<tplarg><title>Foo" ), + array( "{{{ {{Foo}} }}}", " <template><title>Foo " ), + array( "{{ {{{Foo}}} }}", "" ), + array( "{{{{{Foo}}}}}", "" ), + array( "{{{{{Foo}} }}}", "<template><title>Foo " ), + array( "{{{{{{Foo}}}}}}", "<tplarg><title>Foo" ), array( "{{{{{{Foo}}}}}", "{" ), array( "[[[Foo]]", "[[[Foo]]" ), - array( "{{Foo|[[[[bar]]|baz]]}}", "" ), // This test is important, since it means the difference between having the [[ rule stacked or not + array( "{{Foo|[[[[bar]]|baz]]}}", "" ), // This test is important, since it means the difference between having the [[ rule stacked or not array( "{{Foo|[[[[bar]|baz]]}}", "{{Foo|[[[[bar]|baz]]}}" ), array( "{{Foo|Foo [[[[bar]|baz]]}}", "{{Foo|Foo [[[[bar]|baz]]}}" ), array( "Foo BarBaz", "Foo display mapBar</display map >Baz" ), array( "Foo BarBaz", "Foo display map fooBar</display map >Baz" ), array( "Foo ", "Foo gallery bar="baz" " ), array( "Foo", "/fooFoo<//foo>" ), # Worth blacklisting IMHO - array( "{{#ifexpr: ({{{1|1}}} = 2) | Foo | Bar }}", ""), - array( "{{#if: {{{1|}}} | Foo | {{Bar}} }}", ""), - array( "{{#if: {{{1|}}} | Foo | [[Bar]] }}", ""), - array( "{{#if: {{{1|}}} | [[Foo]] | Bar }}", ""), - array( "{{#if: {{{1|}}} | 1 | {{#if: {{{1|}}} | 2 | 3 }} }}", ""), + array( "{{#ifexpr: ({{{1|1}}} = 2) | Foo | Bar }}", ""), + array( "{{#if: {{{1|}}} | Foo | {{Bar}} }}", ""), + array( "{{#if: {{{1|}}} | Foo | [[Bar]] }}", ""), + array( "{{#if: {{{1|}}} | [[Foo]] | Bar }}", ""), + array( "{{#if: {{{1|}}} | 1 | {{#if: {{{1|}}} | 2 | 3 }} }}", ""), array( "{{ {{Foo}}", "{{ "), array( "{{Foobar {{Foo}} {{Bar}} {{Baz}} ", "{{Foobar "), array( "[[Foo]] |", "[[Foo]] |"), @@ -97,10 +96,10 @@ class PreprocessorTest extends MediaWikiTestCase { array( "{{Foo|bar=[[baz]}}", "{{Foo|bar=[[baz]}}"), array( "{{foo|", "{{foo|"), array( "{{foo|}", "{{foo|}"), - array( "{{foo|} }}", ""), + array( "{{foo|} }}", ""), array( "{{foo|bar=|}", "{{foo|bar=|}"), array( "{{Foo|} Bar=", "{{Foo|} Bar="), - array( "{{Foo|} Bar=}}", ""), + array( "{{Foo|} Bar=}}", ""), /* array( file_get_contents( dirname( __FILE__ ) . '/QuoteQuran.txt' ), file_get_contents( dirname( __FILE__ ) . '/QuoteQuranExpanded.txt' ) ), */ ); } -- 2.20.1