From b4ec34def9407d4fdc6f7a2295a41c4768f14c3a Mon Sep 17 00:00:00 2001 From: Leo Koppelkamm Date: Thu, 14 Apr 2011 19:28:45 +0000 Subject: [PATCH] Followup to r86064 (List with double line-breaks inside tables). Also contains patch for Bug 16700 by Mormegil (Additional linebreak though nested templates). Parsertests for both --- includes/parser/Parser.php | 7 +-- includes/parser/Preprocessor_DOM.php | 2 +- includes/parser/Preprocessor_Hash.php | 2 +- tests/parser/parserTests.txt | 65 ++++++++++++++++++++++++++- 4 files changed, 68 insertions(+), 8 deletions(-) diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 6cf1e2bf18..822c966c74 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -831,11 +831,8 @@ class Parser { # empty line, go to next line, # but only append \n if outside of table - if ( $line === '' ) { - $out .= $outLine; - if ( !isset( $tables[0] ) ) { - $out .= "\n"; - } + if ( $line === '') { + $output .= $outLine . "\n"; continue; } $firstChars = $line[0]; diff --git a/includes/parser/Preprocessor_DOM.php b/includes/parser/Preprocessor_DOM.php index af16ff41bf..2587510dea 100644 --- a/includes/parser/Preprocessor_DOM.php +++ b/includes/parser/Preprocessor_DOM.php @@ -521,7 +521,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 baea6817ff..fbbc218aba 100644 --- a/includes/parser/Preprocessor_Hash.php +++ b/includes/parser/Preprocessor_Hash.php @@ -493,7 +493,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 af62b25e5e..6f5b343c6b 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -1433,6 +1433,37 @@ 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 Simple paragraph @@ -1780,6 +1811,8 @@ Arbitrary whitespace should not be prepended 1 2 +


+

@@ -3373,6 +3406,35 @@ 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 ### @@ -5928,6 +5990,7 @@ http://===r:::https://b !!result

http://===r:::https://b +


!! end @@ -5966,7 +6029,7 @@ MOVE YOUR MOUSE CURSOR OVER THIS TEXT

{{{| }}}} >
-MOVE YOUR MOUSE CURSOR OVER THIS TEXT +

MOVE YOUR MOUSE CURSOR OVER THIS TEXT

-- 2.20.1