From: Arlo Breault
Date: Tue, 23 Oct 2018 22:47:48 +0000 (-0400)
Subject: parser: Remove trailing newline after prefixes have been cleared
X-Git-Tag: 1.34.0-rc.0~2477^2~1
X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=8384d48ae019ce0f3732a83235b86e3696891ee9;p=lhc%2Fweb%2Fwiklou.git
parser: Remove trailing newline after prefixes have been cleared
Bug: T208070
Depends-On: I74953d5de765a2245a2999f17c7ae1cf49376bd1
Change-Id: I05511aee275238954f22db78616b19ce10cd6490
---
diff --git a/includes/parser/BlockLevelPass.php b/includes/parser/BlockLevelPass.php
index 288a52704e..b8ff75692a 100644
--- a/includes/parser/BlockLevelPass.php
+++ b/includes/parser/BlockLevelPass.php
@@ -403,7 +403,9 @@ class BlockLevelPass {
while ( $prefixLength ) {
$output .= $this->closeList( $prefix2[$prefixLength - 1] );
--$prefixLength;
- if ( !$prefixLength ) {
+ // Note that `lastSection` is only ever set when `prefixLength`
+ // is zero, but we'll choose to be overly cautious.
+ if ( !$prefixLength && $this->lastSection !== '' ) {
$output .= "\n";
}
}
diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt
index 7ef057a925..d64089b447 100644
--- a/tests/parser/parserTests.txt
+++ b/tests/parser/parserTests.txt
@@ -668,7 +668,6 @@ Simple list
!! html
-
!! end
!! test
@@ -705,7 +704,6 @@ Italics and bold
plainboldbold-italicplain
plain l'italicplain
plain l'bold plain
-
!! end
# this example taken from the [[simple:Moon]] article (T49326)
@@ -1575,7 +1573,6 @@ nowiki 3
There is nowiki.
- There is not nowiki.
- There is nowiki.
-
!! html/parsoid
- There is not nowiki.
- There is nowiki.
@@ -1980,7 +1977,6 @@ parsoid=wt2html,wt2wt
!! html/php
-
!! html/parsoid
- a
@@ -3014,7 +3010,6 @@ Templates: Strip leading and trailing whitespace from named-param values
c
-
!! end
!! test
@@ -4045,7 +4040,6 @@ Simple definition
!! html
- name
- Definition
-
!! end
!! test
@@ -4054,7 +4048,6 @@ Definition list for indentation only
:Indented text
!! html
- Indented text
-
!! end
!! test
@@ -4064,7 +4057,6 @@ Definition list with no space
!! html
- name
- Definition
-
!!end
!! test
@@ -4074,7 +4066,6 @@ Definition list with URL link
!! html
- http://example.com/
- definition
-
!! end
!! test
@@ -4084,7 +4075,6 @@ Definition list with bracketed URL link
!! html
- Example
- Something about it
-
!! end
!! test
@@ -4094,7 +4084,6 @@ Definition list with wikilink containing colon
!! html
- Help:FAQ
- The least-read page on Wikipedia
-
!! end
# At Brion's and JeLuF's insistence... :)
@@ -4105,7 +4094,6 @@ Definition list with news link containing colon
!! html/php
- news:alt.wikipedia.rox
- This isn't even a real newsgroup!
-
!! html/parsoid
- news:alt.wikipedia.rox
- This isn't even a real newsgroup!
!! end
@@ -4116,7 +4104,6 @@ Malformed definition list with colon
;news:alt.wikipedia.rox -- don't crash or enter an infinite loop
!! html
- news:alt.wikipedia.rox -- don't crash or enter an infinite loop
-
!! end
!! test
@@ -4126,7 +4113,6 @@ Definition lists: colon in external link text
!! html
- Wikipedia :The Next Generation
- OK, I made that up
-
!! end
!! test
@@ -4135,7 +4121,6 @@ Definition lists: colon in HTML attribute
;bold
!! html
- bold
-
!! end
!! test
@@ -4145,7 +4130,6 @@ Definition lists: self-closed tag
!! html
- one
two
- two-line fun
-
!! end
!! test
@@ -4155,7 +4139,6 @@ Definition lists: ignore colons inside tags
!! html
- one two : tag fun::
- def
-
!! end
!! test
@@ -4243,7 +4226,6 @@ Definition Lists: No nesting: Multiple dd's
- x
- a
- b
-
!! end
!! test
@@ -4256,7 +4238,6 @@ Definition Lists: Indentation: Regular
- i1
- i2
- i3
-
!! end
!! test
@@ -4267,7 +4248,6 @@ Definition Lists: Indentation: Missing 1st level
!! html
- i2
- i3
-
!! end
!! test
@@ -4276,7 +4256,6 @@ Definition Lists: Indentation: Multi-level indent
:::i3
!! html
- i3
-
!! end
!! test
@@ -4466,7 +4445,6 @@ Table / list interaction: lists nested in tables nested in indented lists
-
!!end
!! test
@@ -4529,7 +4507,6 @@ Definition Lists: Nesting: Test 4
!! html
- t3
- d3
-
!! end
@@ -4549,7 +4526,6 @@ Definition Lists: Mixed Lists: Test 1
- baz
-
!! html/php+tidy
@@ -4578,7 +4554,6 @@ Definition Lists: Mixed Lists: Test 2
!! html
-
!! end
@@ -4590,7 +4565,6 @@ Definition Lists: Mixed Lists: Test 3
!! html
-
!! end
@@ -4604,7 +4578,6 @@ Definition Lists: Mixed Lists: Test 4
- d2
- d3
- d4
-
!! end
@@ -4616,7 +4589,6 @@ Definition Lists: Mixed Lists: Test 5
!! html
-
!! end
@@ -4628,7 +4600,6 @@ Definition Lists: Mixed Lists: Test 6
!! html
-
!! end
@@ -4640,7 +4611,6 @@ Definition Lists: Mixed Lists: Test 7
!! html
-
!! end
@@ -4652,7 +4622,6 @@ Definition Lists: Mixed Lists: Test 8
!! html
-
-
!! end
@@ -4663,7 +4632,6 @@ Definition Lists: Mixed Lists: Test 9
!! html
-
!! end
@@ -4674,7 +4642,6 @@ Definition Lists: Mixed Lists: Test 10
!! html
-
!! end
# The Parsoid team disagrees with the PHP parser's seemingly-random
@@ -4692,7 +4659,6 @@ Definition Lists: Mixed Lists: Test 11
- a
-
-
!! html/parsoid
- a
@@ -4709,7 +4675,6 @@ Definition Lists: Mixed Lists: Test 12
- boo
- baz
-
!! html/php+tidy
-
!! html/parsoid
http://[2404:130:0:1000::187:2]/index.php
@@ -6025,7 +5989,6 @@ Examples from RFC 2732, section 2:
5
6
7
-
!! html/parsoid
test
@@ -8866,7 +8829,6 @@ parsoid=wt2html,wt2wt
!! html/php
-
!! html/php+tidy
@@ -9873,7 +9835,6 @@ Common list
- Common list
- item 2
- item 3
-
!! end
!! test
@@ -9886,7 +9847,6 @@ Numbered list
- Numbered list
- item 2
- item 3
-
!! end
# the switch from level 3 to ordered should not introduce a newline between
@@ -9924,7 +9884,6 @@ Mixed list
Level 1
-
!! end
!! test
@@ -9939,7 +9898,6 @@ Mixed list
hi
-
!! html/parsoid
- hi
@@ -9955,7 +9913,6 @@ Mixed list
!! html/php
- hi
- ho
-
!! html/parsoid
- hi
- ho
@@ -9969,7 +9926,6 @@ Nested lists 1
!! html
-
!! end
!! test
@@ -9980,7 +9936,6 @@ Nested lists 2
!! html
-
!! end
!! test
@@ -9991,7 +9946,6 @@ Nested lists 3 (first element empty)
!! html
-
!! end
!! test
@@ -10002,7 +9956,6 @@ Nested lists 4 (first element empty)
!! html
-
!! end
!! test
@@ -10013,7 +9966,6 @@ Nested lists 5 (both elements empty)
!! html
-
!! end
!! test
@@ -10024,7 +9976,6 @@ Nested lists 6 (both elements empty)
!! html
-
!! end
!! test
@@ -10033,7 +9984,6 @@ Nested lists 7 (skip initial nesting levels)
***foo
!! html
-
!! end
!! test
@@ -10048,7 +9998,6 @@ Nested lists 8 (multiple nesting transitions)
- boo
-
!! end
# XXX this test should be moved to citeParserTests, since it depends
@@ -10073,7 +10022,6 @@ Nested lists 9 (extension interaction)
-
!! end
!! test
@@ -10094,7 +10042,6 @@ Nested lists 10 (list and span siblings: wt2wt regression)
!! html
-
!! end
!! test
@@ -10107,7 +10054,6 @@ List items are not parsed correctly following a block (T2785)
-
!! html/parsoid
foo
bar
@@ -10139,7 +10085,6 @@ List items from template
- notSOL
- item 1
- item 2
-
!! end
!! test
@@ -10155,7 +10100,6 @@ List interrupted by empty line or heading
A heading[edit]
-
!!end
!! test
@@ -10235,7 +10179,6 @@ Single-comment whitespace lines dont break lists, and neither do multi-comment w
b
c
d
-
!!end
!!test
@@ -10254,7 +10197,6 @@ Replacing whitespace with tabs still doesn't break the list (gerrit 78327)
b
c
d
-
!!end
# FIXME: Parsoid has a dedicated DOM pass to mimic this Tidy-specific li-hack
@@ -10620,7 +10562,6 @@ Magic Words LOCAL (UTC)
1
4
19700101000203
-
!! end
!! test
@@ -11694,7 +11635,6 @@ Templates with templated name
foo
-
!! html/parsoid
foo
@@ -12558,7 +12498,6 @@ Preprocessor precedence 5: tplarg takes precedence over template
{{Precedence5|Bullet}}
!! html/php
-
!! html/parsoid
!! end
@@ -12658,7 +12597,6 @@ Preprocessor precedence 9: groups of braces
Four
7
{Bullet}
-
!! html/parsoid
- 4
@@ -12710,7 +12648,6 @@ language=zh
- -Three-
- 7
- raw2
-
!! html/parsoid
- 1
@@ -13763,7 +13700,6 @@ unused}}}}
!! html
-
!!end
!!test
@@ -21201,7 +21137,6 @@ Handling of
in URLs
*irc://
a
!! html/php
-
!! html/parsoid
!! end
@@ -21212,7 +21147,6 @@ Handling of %0A in URLs
*irc://%0Aa
!! html/php
-
!! html/parsoid
!! end
@@ -21329,7 +21263,6 @@ title=[[Parser test]]
Template:Dynamic
-
!! end
### Note: Above tests excludes the "{{NUMBEROFADMINS}}" magic word because it generates a MySQL error when included.
@@ -22320,7 +22253,6 @@ dt/dd/dl test
:;;;::
!! html/php
-
!! html/parsoid
@@ -22479,7 +22411,6 @@ Definition list code coverage
def
title
def
-
!! html/parsoid
- title
- def
- title
- def
@@ -23885,7 +23816,6 @@ language=zh variant=zh-cn
!! html/php
- AAA
- foo:bar
-
!! html/parsoid
@@ -23903,8 +23833,7 @@ language=zh variant=zh-cn
;-{zh-cn:AAA
!! html/php+tidy
- foo:bar
-- -{zh-cn:AAA
-
+- -{zh-cn:AAA
!! html/parsoid
- foo:bar
- -{zh-cn
- AAA
@@ -23919,7 +23848,6 @@ language=zh variant=zh-cn
!! html/php
- AAA foo:bar bat:baz
- def
-
!! html/parsoid
- def
@@ -24076,7 +24004,6 @@ T2529: Uncovered bullet
!! html
-
!! end
!! test
@@ -24086,7 +24013,6 @@ T2529: Uncovered bullet in a deeply nested list
!! html
-
!! end
!! test
@@ -24119,7 +24045,6 @@ T2529: Uncovered bullet in parser function result
!! html
-
!! end
!! test
@@ -24949,7 +24874,6 @@ paragraphs
04=
05=
-
06=foo
07=Preformatted
diff --git a/tests/phpunit/includes/OutputPageTest.php b/tests/phpunit/includes/OutputPageTest.php
index aa14124a2c..92765cb0d0 100644
--- a/tests/phpunit/includes/OutputPageTest.php
+++ b/tests/phpunit/includes/OutputPageTest.php
@@ -1534,7 +1534,7 @@ class OutputPageTest extends MediaWikiTestCase {
'' . "\nMy message\n
"
], 'List at start' => [
[ '* List' ],
- "\n",
+ "",
], 'List not at start' => [
[ '* Not a list', false ],
'* Not a list
',
@@ -1829,12 +1829,12 @@ class OutputPageTest extends MediaWikiTestCase {
return [
'List at start of line (content)' => [
[ '* List', true, false ],
- "",
- "\n",
+ "",
+ "",
],
'List at start of line (interface)' => [
[ '* List', true, true ],
- "\n",
+ "",
],
'List not at start (content)' => [
[ "* ''Not'' list", false, false ],
@@ -1925,7 +1925,7 @@ class OutputPageTest extends MediaWikiTestCase {
return [
'List at start of line' => [
[ '* List', true ],
- "\n",
+ "",
],
'List not at start' => [
[ "* ''Not'' list", false ],