From b9d0e5e4e763aa58647f88739ed0e5682685d064 Mon Sep 17 00:00:00 2001 From: "C. Scott Ananian" Date: Tue, 6 Aug 2013 15:22:18 -0400 Subject: [PATCH] Make line breaks in
behave like
(bug 6200). This is an old, old bug: the earliest filed dup is bug 1857, on 2005-04-10. However, it was not too hard to fix. See bug 51086 for a modern discussion. With this patch the PHP parser matches the Parsoid output. This also fixes (or works around) bug 15491, which is really a bug in tidy. But because
content is typically wrapped with

tags now, we don't trigger the tidy bug (see https://bugzilla.wikimedia.org/show_bug.cgi?id=15491#c7 for details). Credit to Aryeh Gregor (https://bugzilla.wikimedia.org/show_bug.cgi?id=6200#c8) and Vitaliy Filippov (https://bugzilla.wikimedia.org/show_bug.cgi?id=6200#c37) for almost-correct patches for this bug, which saved me a bunch of effort. Bug: 6200 Bug: 15491 Change-Id: Iecab69460c6aac36acfe2d9440dc5d3590de8b57 --- RELEASE-NOTES-1.22 | 1 + includes/parser/Parser.php | 6 ++-- tests/parser/parserTests.txt | 67 +++++++++++++++++++++++++++++++++----------- 3 files changed, 55 insertions(+), 19 deletions(-) diff --git a/RELEASE-NOTES-1.22 b/RELEASE-NOTES-1.22 index 51ea25464f0..72d91b726f3 100644 --- a/RELEASE-NOTES-1.22 +++ b/RELEASE-NOTES-1.22 @@ -244,6 +244,7 @@ production. revision as second argument now, rather than just the current section. * (bug 49694) $wgSpamRegex is now also applied on the new section headline text adding a new topic on a page +* (bug 6200) line breaks in

are handled like they are in
=== API changes in 1.22 === * (bug 25553) The JSON output formatter now leaves forward slashes unescaped diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index ac0bae5c5a4..4a16f565302 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -2405,10 +2405,10 @@ class Parser { wfProfileIn( __METHOD__ . "-paragraph" ); # No prefix (not in list)--go to paragraph mode # XXX: use a stack for nestable elements like span, table and div - $openmatch = preg_match( '/(?:mUniqPrefix . '-pre|<\\/li|<\\/ul|<\\/ol|<\\/dl|<\\/?center)/iS', $t ); + '/(?:<\\/table|<\\/h1|<\\/h2|<\\/h3|<\\/h4|<\\/h5|<\\/h6|' . + 'mUniqPrefix . '-pre|<\\/li|<\\/ul|<\\/ol|<\\/dl|<\\/?center)/iS', $t ); if ( $openmatch or $closematch ) { $paragraphStack = false; # TODO bug 5718: paragraph closed diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index bdafad8fb90..a9e5dee4719 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -1338,8 +1338,6 @@ Regression with preformatted in
!! end -# Expected output in the following test is not really expected (there should be -#
 in the output) -- it's only testing for well-formedness.
 !! test
 Bug 6200: Preformatted in 
!! input @@ -1348,7 +1346,53 @@ Bug 6200: Preformatted in
!! result
- Blah +
Blah
+
+
+ +!! end + +!! test +Bug 51086: Double newlines in blockquotes should be turned into paragraphs +!! input +
+Foo + +Bar +
+!! result +
+

Foo +

Bar +

+
+ +!! end + +!! test +Bug 15491: / in blockquote +!! input +
+Foo bar baz quux +
+!! result +
+

Foo bar baz quux +

+
+ +!! end + +# Note that the p-wrapping is newline sensitive, which could be +# considered a bug: tidy will wrap only the 'Foo' in the example +# below in a

tag. (see comment 23-25 of bug #6200) +!! test +Bug 15491: / in blockquote (2) +!! input +

Foo bar baz quux +
+!! result +
Foo bar baz quux
!! end @@ -1849,7 +1893,8 @@ c
- foo +
foo
+
foo
@@ -12882,9 +12927,6 @@ __NOEDITSECTION__
 

!! end -# Expected output in the following test is not necessarily expected (there -# should probably be

tags inside the

in the output) -- it's -# only testing for well-formedness. !! test Bug 6200: blockquotes and paragraph formatting !! input @@ -12897,7 +12939,8 @@ bar baz !! result
-foo +

foo +

bar

@@ -13583,8 +13626,6 @@ B # Bug 6200:
should behave like
with respect to line breaks !! test Bug 6200: paragraphs inside blockquotes (no extra line breaks) -!! options -disabled !! input
Line one @@ -13597,8 +13638,6 @@ Line two
!! test Bug 6200: paragraphs inside blockquotes (extra line break on open) -!! options -disabled !! input
Line one @@ -13614,8 +13653,6 @@ Line two
!! test Bug 6200: paragraphs inside blockquotes (extra line break on close) -!! options -disabled !! input
Line one @@ -13631,8 +13668,6 @@ Line two !! test Bug 6200: paragraphs inside blockquotes (extra line break on open and close) -!! options -disabled !! input
Line one -- 2.11.4.GIT