Make line breaks in <blockquote> behave like <div> (bug 6200).
authorC. Scott Ananian <cscott@cscott.net>
Tue, 6 Aug 2013 19:22:18 +0000 (15:22 -0400)
committerC. Scott Ananian <cscott@cscott.net>
Tue, 6 Aug 2013 19:33:19 +0000 (15:33 -0400)
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 <blockquote> content is typically wrapped with <p> 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
includes/parser/Parser.php
tests/parser/parserTests.txt

index 51ea254..72d91b7 100644 (file)
@@ -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 <blockquote> are handled like they are in <div>
 
 === API changes in 1.22 ===
 * (bug 25553) The JSON output formatter now leaves forward slashes unescaped
index ac0bae5..4a16f56 100644 (file)
@@ -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( '/(?:<table|<blockquote|<h1|<h2|<h3|<h4|<h5|<h6|<pre|<tr|<p|<ul|<ol|<dl|<li|<\\/tr|<\\/td|<\\/th)/iS', $t );
+                               $openmatch = preg_match( '/(?:<table|<h1|<h2|<h3|<h4|<h5|<h6|<pre|<tr|<p|<ul|<ol|<dl|<li|<\\/tr|<\\/td|<\\/th)/iS', $t );
                                $closematch = preg_match(
-                                       '/(?:<\\/table|<\\/blockquote|<\\/h1|<\\/h2|<\\/h3|<\\/h4|<\\/h5|<\\/h6|' .
-                                       '<td|<th|<\\/?div|<hr|<\\/pre|<\\/p|' . $this->mUniqPrefix . '-pre|<\\/li|<\\/ul|<\\/ol|<\\/dl|<\\/?center)/iS', $t );
+                                       '/(?:<\\/table|<\\/h1|<\\/h2|<\\/h3|<\\/h4|<\\/h5|<\\/h6|' .
+                                       '<td|<th|<\\/?blockquote|<\\/?div|<hr|<\\/pre|<\\/p|' . $this->mUniqPrefix . '-pre|<\\/li|<\\/ul|<\\/ol|<\\/dl|<\\/?center)/iS', $t );
                                if ( $openmatch or $closematch ) {
                                        $paragraphStack = false;
                                        # TODO bug 5718: paragraph closed
index bdafad8..a9e5dee 100644 (file)
@@ -1338,8 +1338,6 @@ Regression with preformatted in <center>
 
 !! end
 
-# Expected output in the following test is not really expected (there should be
-# <pre> in the output) -- it's only testing for well-formedness.
 !! test
 Bug 6200: Preformatted in <blockquote>
 !! input
@@ -1348,7 +1346,53 @@ Bug 6200: Preformatted in <blockquote>
 </blockquote>
 !! result
 <blockquote>
- Blah
+<pre>Blah
+</pre>
+</blockquote>
+
+!! end
+
+!! test
+Bug 51086: Double newlines in blockquotes should be turned into paragraphs
+!! input
+<blockquote>
+Foo
+
+Bar
+</blockquote>
+!! result
+<blockquote>
+<p>Foo
+</p><p>Bar
+</p>
+</blockquote>
+
+!! end
+
+!! test
+Bug 15491: <ins>/<del> in blockquote
+!! input
+<blockquote>
+Foo <del>bar</del> <ins>baz</ins> quux
+</blockquote>
+!! result
+<blockquote>
+<p>Foo <del>bar</del> <ins>baz</ins> quux
+</p>
+</blockquote>
+
+!! 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 <p> tag. (see comment 23-25 of bug #6200)
+!! test
+Bug 15491: <ins>/<del> in blockquote (2)
+!! input
+<blockquote>Foo <del>bar</del> <ins>baz</ins> quux
+</blockquote>
+!! result
+<blockquote>Foo <del>bar</del> <ins>baz</ins> quux
 </blockquote>
 
 !! end
@@ -1849,7 +1893,8 @@ c
 </pre>
 </center>
 <blockquote>
- foo
+<pre>foo
+</pre>
 </blockquote>
 <table><tr><td>
 <pre>foo
@@ -12882,9 +12927,6 @@ __NOEDITSECTION__
 </p>
 !! end
 
-# Expected output in the following test is not necessarily expected (there
-# should probably be <p> tags inside the <blockquote> 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
 <blockquote>
-foo
+<p>foo
+</p>
 </blockquote>
 <p>bar
 </p>
@@ -13583,8 +13626,6 @@ B</strong>
 # Bug 6200: <blockquote> should behave like <div> with respect to line breaks
 !! test
 Bug 6200: paragraphs inside blockquotes (no extra line breaks)
-!! options
-disabled
 !! input
 <blockquote>Line one
 
@@ -13597,8 +13638,6 @@ Line two</blockquote>
 
 !! test
 Bug 6200: paragraphs inside blockquotes (extra line break on open)
-!! options
-disabled
 !! input
 <blockquote>
 Line one
@@ -13614,8 +13653,6 @@ Line two</blockquote>
 
 !! test
 Bug 6200: paragraphs inside blockquotes (extra line break on close)
-!! options
-disabled
 !! input
 <blockquote>Line one
 
@@ -13631,8 +13668,6 @@ Line two
 
 !! test
 Bug 6200: paragraphs inside blockquotes (extra line break on open and close)
-!! options
-disabled
 !! input
 <blockquote>
 Line one