Page MenuHomePhabricator

Parser-new-doblocklevels-r105865.diff

Authored By
bzimport
Nov 21 2014, 9:22 PM
Size
38 KB
Referenced Files
None
Subscribers
None

Parser-new-doblocklevels-r105865.diff

Index: skins/chick/main.css
===================================================================
--- skins/chick/main.css (revision 105869)
+++ skins/chick/main.css (working copy)
@@ -27,12 +27,12 @@
border: none;
vertical-align: middle;
}
-p {
+p, div.paragraph {
margin: 0.4em 0em 0.5em 0em;
line-height: 1.5em;
}
-p img { margin: 0; }
+p img, div.paragraph img { margin: 0; }
hr {
height: 1px;
@@ -189,7 +189,7 @@
font-size: 95%;
padding: 0 0.9em 0 0.9em;
}
-#siteNotice p { margin: 0; padding: 0; }
+#siteNotice p, div.paragraph { margin: 0; padding: 0; }
.error {
color: red;
font-size: larger;
@@ -240,13 +240,13 @@
border: 0.5em solid white;
border-width: 0.5em 0 0.8em 1.4em;
}
-div.floatright p { font-style: italic; }
+div.floatright p, div.floatright div.paragraph { font-style: italic; }
/* @noflip */div.floatleft, table.floatleft {
margin: 0.3em 0.5em 0.5em 0;
border: 0.5em solid white;
border-width: 0.5em 1.4em 0.8em 0;
}
-div.floatleft p { font-style: italic; }
+div.floatleft p, div.floatleft div.paragraph { font-style: italic; }
/* thumbnails */
div.thumb {
margin-bottom: 0.5em;
Index: skins/nostalgia/screen.css
===================================================================
--- skins/nostalgia/screen.css (revision 105869)
+++ skins/nostalgia/screen.css (working copy)
@@ -43,7 +43,7 @@
overflow: auto;
}
-p.subtitle {
+p.subtitle, div.paragraph.subtitle {
padding-top: 0;
margin-top: 0;
}
Index: skins/monobook/main.css
===================================================================
--- skins/monobook/main.css (revision 105869)
+++ skins/monobook/main.css (working copy)
@@ -98,7 +98,7 @@
#localNotice {
margin: 0;
}
-#siteNotice p {
+#siteNotice p, #siteNotice div.paragraph {
margin: 0;
padding: 0;
}
@@ -843,7 +843,7 @@
padding: 2px;
}
-#powersearch p {
+#powersearch p, #powersearch div.paragraph {
margin-top:0px;
}
Index: skins/modern/main.css
===================================================================
--- skins/modern/main.css (revision 105869)
+++ skins/modern/main.css (working copy)
@@ -282,7 +282,7 @@
display: none;
}
-p {
+p, div.paragraph {
margin: 1em 0 1em 0;
}
@@ -477,14 +477,14 @@
margin: 0 0 .5em .5em;
border: 0;
}
-div.floatright p {
+div.floatright p, div.floatright div.paragraph {
font-style: italic;
}
/* @noflip */div.floatleft, table.floatleft {
margin: 0 .5em .5em 0;
border: 0;
}
-div.floatleft p {
+div.floatleft p, div.floatleft div.paragraph {
font-style: italic;
}
@@ -646,7 +646,7 @@
margin-bottom: 1em;
}
-.previewnote p {
+.previewnote p, .previewnote div.paragraph {
margin: 0;
padding: 0;
}
@@ -833,7 +833,7 @@
background: url(footer-grad.png) repeat-x bottom left;
}
-.mw-topbox p {
+.mw-topbox p, .mw-topbox div.paragraph {
padding: 0 0 0 0;
margin: 0 0 0 0;
}
Index: skins/common/oldshared.css
===================================================================
--- skins/common/oldshared.css (revision 105869)
+++ skins/common/oldshared.css (working copy)
@@ -39,7 +39,7 @@
}
/* @noflip */
-div.floatright p {
+div.floatright p, div.floatright div.paragraph {
font-style: italic;
}
@@ -51,7 +51,7 @@
}
/* @noflip */
-div.floatleft p {
+div.floatleft p, div.floatleft div.paragraph {
font-style: italic;
}
Index: skins/common/commonPrint.css
===================================================================
--- skins/common/commonPrint.css (revision 105869)
+++ skins/common/commonPrint.css (working copy)
@@ -26,7 +26,8 @@
position: relative;
margin: 0.5em 0 0.8em 1.4em;
}
-div.floatright p {
+div.floatright p,
+div.floatright div.paragraph {
font-style: italic;
}
div.floatleft {
@@ -35,7 +36,8 @@
position: relative;
margin: 0.5em 1.4em 0.8em 0;
}
-div.floatleft p {
+div.floatleft p,
+div.floatleft div.paragraph {
font-style: italic;
}
div.center {
@@ -152,7 +154,7 @@
font-weight: bold;
}
-p {
+p, div.paragraph {
margin: 1em 0;
line-height: 1.2em;
}
@@ -351,7 +353,7 @@
h2, h3, h4, h5, h6, h7 {
page-break-after: avoid;
}
-p {
+p, div.paragraph {
widows: 3;
orphans: 3;
}
Index: skins/common/shared.css
===================================================================
--- skins/common/shared.css (revision 105869)
+++ skins/common/shared.css (working copy)
@@ -318,7 +318,12 @@
p.mw-protect-editreasons,
p.mw-filedelete-editreasons,
p.mw-delete-editreasons,
-p.mw-revdel-editreasons {
+p.mw-revdel-editreasons,
+div.paragraph.mw-ipb-conveniencelinks,
+div.paragraph.mw-protect-editreasons,
+div.paragraph.mw-filedelete-editreasons,
+div.paragraph.mw-delete-editreasons,
+div.paragraph.mw-revdel-editreasons {
font-size: 90%;
text-align: right;
}
@@ -562,7 +567,8 @@
margin-bottom: 1em;
}
-.previewnote p {
+.previewnote p,
+.previewnote div.paragraph {
text-indent: 3em;
margin: 0.8em 0;
}
Index: skins/common/wikistandard.css
===================================================================
--- skins/common/wikistandard.css (revision 105869)
+++ skins/common/wikistandard.css (working copy)
@@ -152,11 +152,13 @@
background-color: gray;
}
-p.subpages {
+p.subpages,
+div.paragraph.subpages {
font-size: small;
}
-p.subtitle {
+p.subtitle,
+div.paragraph.subtitle {
padding-top: 0;
margin-top: 0;
}
Index: skins/simple/main.css
===================================================================
--- skins/simple/main.css (revision 105869)
+++ skins/simple/main.css (working copy)
@@ -102,11 +102,11 @@
img {
border: none;
}
-p {
+p, div.paragraph {
margin: 0.4em 0em 0.5em 0em;
line-height: 1.5em;
}
-p img {
+p img, div.paragraph img {
margin: 0;
}
@@ -290,14 +290,14 @@
margin: 0;
border-width: 0.5em 0 0.8em 1.4em;
}
-div.floatright p {
+div.floatright p, div.floatright div.paragraph {
font-style: italic;
}
/* @noflip */div.floatleft, table.floatleft {
margin: 0.3em 0.5em 0.5em 0;
border-width: 0.5em 1.4em 0.8em 0;
}
-div.floatleft p {
+div.floatleft p, div.floatleft div.paragraph {
font-style: italic;
}
Index: skins/cologneblue/screen.css
===================================================================
--- skins/cologneblue/screen.css (revision 105869)
+++ skins/cologneblue/screen.css (working copy)
@@ -39,20 +39,20 @@
z-index: 99;
}
-#article, #article td, #article th, #article p {
+#article, #article td, #article th, #article p, #article div.paragraph {
font-family: Verdana, Arial, sans-serif;
font-size: 10pt;
color: black;
}
-#article p {
+#article p, #article div.paragraph {
padding-top: 0;
padding-bottom: 0;
margin-top: 1ex;
margin-bottom: 0;
}
-p, pre, td, th, li, dd, dt {
+p, div.paragraph, pre, td, th, li, dd, dt {
line-height: 12pt;
}
@@ -182,7 +182,7 @@
margin-bottom: 0;
}
-#article p.subtitle {
+#article p.subtitle, #article div.paragraph {
color: #666666;
font-size: 11pt;
font-weight: bold;
Index: tests/parser/parserTests.txt
===================================================================
--- tests/parser/parserTests.txt (revision 105869)
+++ tests/parser/parserTests.txt (working copy)
@@ -198,7 +198,6 @@
!! result
<pre>asdf
</pre>
-
!! end
!! test
@@ -243,11 +242,9 @@
c
!! result
<p>a
+</p><pre> b
+</pre><p>c
</p>
-<pre> b
-</pre>
-<p>c
-</p>
!! end
!! test
@@ -371,8 +368,7 @@
!! result
<center>
<pre>Blah
-</pre>
-</center>
+</pre></center>
!! end
@@ -386,8 +382,8 @@
</blockquote>
!! result
<blockquote>
- Blah
-</blockquote>
+<pre>Blah
+</pre></blockquote>
!! end
@@ -2056,8 +2052,8 @@
!! result
<hr />
<hr />
-foo <hr /> bar
-
+<p>foo </p><hr /><p> bar
+</p>
!! end
###
@@ -2759,8 +2755,8 @@
{{paramtest|
param =[[Image:noimage.png|thumb|[[no link|link]] [[no link|caption]]]]}}
!! result
-This is a test template with parameter <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/index.php?title=Special:Upload&amp;wpDestFile=Noimage.png" class="new" title="File:Noimage.png">File:Noimage.png</a> <div class="thumbcaption"><a href="/index.php?title=No_link&amp;action=edit&amp;redlink=1" class="new" title="No link (page does not exist)">link</a> <a href="/index.php?title=No_link&amp;action=edit&amp;redlink=1" class="new" title="No link (page does not exist)">caption</a></div></div></div>
-
+<div class="paragraph">This is a test template with parameter <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/index.php?title=Special:Upload&amp;wpDestFile=Noimage.png" class="new" title="File:Noimage.png">File:Noimage.png</a> <div class="thumbcaption"><a href="/index.php?title=No_link&amp;action=edit&amp;redlink=1" class="new" title="No link (page does not exist)">link</a> <a href="/index.php?title=No_link&amp;action=edit&amp;redlink=1" class="new" title="No link (page does not exist)">caption</a></div></div></div>
+</div>
!! end
!! article
@@ -2897,8 +2893,7 @@
foo {{table}}
!! result
<p>foo
-</p>
-<table>
+</p><table>
<tr>
<td> 1 </td>
<td> 2
@@ -2917,8 +2912,7 @@
{{table}}
!! result
<p>foo
-</p>
-<table>
+</p><table>
<tr>
<td> 1 </td>
<td> 2
@@ -4130,11 +4124,9 @@
!! result
<h2><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: Headline 1">edit</a>]</span> <span class="mw-headline" id="Headline_1"> Headline 1 </span></h2>
<p>Some text
-</p>
-<h2><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: Headline 2">edit</a>]</span> <span class="mw-headline" id="Headline_2">Headline 2</span></h2>
+</p><h2><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: Headline 2">edit</a>]</span> <span class="mw-headline" id="Headline_2">Headline 2</span></h2>
<p>More
-</p>
-<h3><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: Smaller headline">edit</a>]</span> <span class="mw-headline" id="Smaller_headline">Smaller headline</span></h3>
+</p><h3><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: Smaller headline">edit</a>]</span> <span class="mw-headline" id="Smaller_headline">Smaller headline</span></h3>
<p>Blah blah
</p>
!! end
@@ -4179,8 +4171,7 @@
<h6><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: Skipping a level">edit</a>]</span> <span class="mw-headline" id="Skipping_a_level_2"> Skipping a level </span></h6>
<h2><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=5" title="Edit section: Headline 2">edit</a>]</span> <span class="mw-headline" id="Headline_2"> Headline 2 </span></h2>
<p>Some text
-</p>
-<h3><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=6" title="Edit section: Another headline">edit</a>]</span> <span class="mw-headline" id="Another_headline">Another headline</span></h3>
+</p><h3><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=6" title="Edit section: Another headline">edit</a>]</span> <span class="mw-headline" id="Another_headline">Another headline</span></h3>
!! end
@@ -4454,8 +4445,7 @@
!! result
<h1><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: =">edit</a>]</span> <span class="mw-headline" id=".3D">=</span></h1>
<p>The line above must have a trailing space!
-</p>
-<h1><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: =">edit</a>]</span> <span class="mw-headline" id=".3D_2">=</span></h1>
+</p><h1><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: =">edit</a>]</span> <span class="mw-headline" id=".3D_2">=</span></h1>
<p>But just in case it doesn't...
</p>
!! end
@@ -4481,8 +4471,7 @@
section 5
!! result
<p>The tooltips shall not show entities to the user (ie. be double escaped)
-</p>
-<table id="toc" class="toc"><tr><td><div id="toctitle"><h2>Contents</h2></div>
+</p><table id="toc" class="toc"><tr><td><div id="toctitle"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1 tocsection-1"><a href="#text_.3E_text"><span class="tocnumber">1</span> <span class="toctext">text &gt; text</span></a></li>
<li class="toclevel-1 tocsection-2"><a href="#text_.3C_text"><span class="tocnumber">2</span> <span class="toctext">text &lt; text</span></a></li>
@@ -4493,17 +4482,13 @@
</td></tr></table>
<h2><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: text > text">edit</a>]</span> <span class="mw-headline" id="text_.3E_text"> text &gt; text </span></h2>
<p>section 1
-</p>
-<h2><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: text &lt; text">edit</a>]</span> <span class="mw-headline" id="text_.3C_text"> text &lt; text </span></h2>
+</p><h2><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: text &lt; text">edit</a>]</span> <span class="mw-headline" id="text_.3C_text"> text &lt; text </span></h2>
<p>section 2
-</p>
-<h2><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: text &amp; text">edit</a>]</span> <span class="mw-headline" id="text_.26_text"> text &amp; text </span></h2>
+</p><h2><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: text &amp; text">edit</a>]</span> <span class="mw-headline" id="text_.26_text"> text &amp; text </span></h2>
<p>section 3
-</p>
-<h2><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: text ' text">edit</a>]</span> <span class="mw-headline" id="text_.27_text"> text ' text </span></h2>
+</p><h2><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: text ' text">edit</a>]</span> <span class="mw-headline" id="text_.27_text"> text ' text </span></h2>
<p>section 4
-</p>
-<h2><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=5" title="Edit section: text &quot; text">edit</a>]</span> <span class="mw-headline" id="text_.22_text"> text " text </span></h2>
+</p><h2><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=5" title="Edit section: text &quot; text">edit</a>]</span> <span class="mw-headline" id="text_.22_text"> text " text </span></h2>
<p>section 5
</p>
!! end
@@ -4681,8 +4666,8 @@
!! input
[[Media:Foobar.jpg|Safe Link<div style=display:none>" onmouseover="alert(document.cookie)" onfoo="</div>]]
!! result
-<a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Safe Link&lt;div style="display:none"&gt;" onmouseover="alert(document.cookie)" onfoo="&lt;/div&gt;</a>
-
+<div class="paragraph"><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Safe Link&lt;div style="display:none"&gt;" onmouseover="alert(document.cookie)" onfoo="&lt;/div&gt;</a>
+</div>
!! end
!! test
@@ -5220,8 +5205,8 @@
string(5) "<tag>"
array(0) {
}
-</pre>&lt;/tag&gt;
-
+</pre><p>&lt;/tag&gt;
+</p>
!! end
!! test
@@ -5271,8 +5256,8 @@
["foo"]=>
string(3) "bar"
}
-</pre>text
-
+</pre><p>text
+</p>
!! end
# </tag> should be output literally since there is no matching tag that begins it
@@ -5322,8 +5307,7 @@
<!-- <statictag>hello, world</statictag> -->
<statictag action=flush/>
!! result
-<p><br />
-</p>
+<p><br /></p>
!! end
# Nested template calls; this case was broken by Parser.php rev 1.506,
@@ -5359,7 +5343,7 @@
!! input
<s></s><table></table>
!! result
-<s></s><table></table>
+<p><s></s></p><table></table>
!! end
@@ -5705,7 +5689,7 @@
http://__TOC__
!! result
<h2><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: onmouseover=">edit</a>]</span> <span class="mw-headline" id="onmouseover.3D"> onmouseover= </span></h2>
-http://<table id="toc" class="toc"><tr><td><div id="toctitle"><h2>Contents</h2></div>
+<p>http://</p><table id="toc" class="toc"><tr><td><div id="toctitle"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
</ul>
@@ -5773,8 +5757,7 @@
{|
!!result
<p><a rel="nofollow" class="external free" href="http://===r:::https://b">http://===r:::https://b</a>
-</p>
-<table>
+</p><table>
<tr><td></td></tr>
</table>
@@ -5796,12 +5779,11 @@
|
!! result
<table>
-{{{|
+<p>{{{|
<u class="&#124;">}}}} &gt;
<br style="onmouseover=&#39;alert(document.cookie);&#39;" />
-
-MOVE YOUR MOUSE CURSOR OVER THIS TEXT
-<tr>
+</p><p>MOVE YOUR MOUSE CURSOR OVER THIS TEXT
+</p><tr>
<td></u>
</td>
</tr>
@@ -5856,7 +5838,7 @@
!! input
http://example.com<pre>junk</pre>
!! result
-<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a><pre>junk</pre>
+<p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></p><pre>junk</pre>
!!end
@@ -5987,9 +5969,7 @@
!! input
{{Special:Prefixindex/Xyzzyx}}
!! result
-<p><br />
-</p>
-<table border="0" id="mw-prefixindex-list-table"><tr><td><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></td></tr></table>
+<p><br /></p><table border="0" id="mw-prefixindex-list-table"><tr><td><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></td></tr></table>
!! end
@@ -6000,12 +5980,8 @@
{{Special:Prefixindex/Xyzzyx}}
{{Special:Prefixindex/Xyzzyx}}
!! result
-<p><br />
-</p>
-<table border="0" id="mw-prefixindex-list-table"><tr><td><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></td></tr></table>
-<p><br />
-</p>
-<table border="0" id="mw-prefixindex-list-table"><tr><td><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></td></tr></table>
+<p><br /></p><table border="0" id="mw-prefixindex-list-table"><tr><td><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></td></tr></table>
+<p><br /></p><table border="0" id="mw-prefixindex-list-table"><tr><td><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></td></tr></table>
!! end
@@ -6935,13 +6911,9 @@
</li><li> Talk:Parser_test
</li><li> Parser test
</li><li> Parser_test
-</li><li>
-</li><li>
+</li><li></li><li></li><li> Talk
</li><li> Talk
-</li><li> Talk
-</li><li>
-</li><li>
-</li><li> <a href="/index.php?title=Template:Dynamic&amp;action=edit&amp;redlink=1" class="new" title="Template:Dynamic (page does not exist)">Template:Dynamic</a>
+</li><li></li><li></li><li> <a href="/index.php?title=Template:Dynamic&amp;action=edit&amp;redlink=1" class="new" title="Template:Dynamic (page does not exist)">Template:Dynamic</a>
</li></ul>
!! end
@@ -6971,8 +6943,7 @@
<div style="height: 150px;">Image2.gif</div>
<div class="gallerytext">
<p>||||
-</p>
- </div>
+ </p></div>
</div></li>
<li class="gallerybox" style="width: 155px"><div style="width: 155px">
<div style="height: 150px;">Image3</div>
@@ -6983,15 +6954,13 @@
<div style="height: 150px;">Image4</div>
<div class="gallerytext">
<p>300px| centre
-</p>
- </div>
+ </p></div>
</div></li>
<li class="gallerybox" style="width: 155px"><div style="width: 155px">
<div style="height: 150px;">Image5.svg</div>
<div class="gallerytext">
<p><a rel="nofollow" class="external free" href="http://///////">http://///////</a>
-</p>
- </div>
+ </p></div>
</div></li>
<li class="gallerybox" style="width: 155px"><div style="width: 155px">
<div style="height: 150px;">* image6</div>
@@ -7019,8 +6988,7 @@
<div style="height: 70px;">Nonexistant.jpg</div>
<div class="gallerytext">
<p>caption
-</p>
- </div>
+ </p></div>
</div></li>
<li class="gallerybox" style="width: 105px"><div style="width: 105px">
<div style="height: 70px;">Nonexistant.jpg</div>
@@ -7031,8 +6999,7 @@
<div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="70" height="8" /></a></div></div>
<div class="gallerytext">
<p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
-</p>
- </div>
+ </p></div>
</div></li>
<li class="gallerybox" style="width: 105px"><div style="width: 105px">
<div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="70" height="8" /></a></div></div>
@@ -7043,8 +7010,7 @@
<div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="This is a foo-bar." src="http://example.com/images/3/3a/Foobar.jpg" width="70" height="8" /></a></div></div>
<div class="gallerytext">
<p>Blabla|blabla.
-</p>
- </div>
+ </p></div>
</div></li>
</ul>
@@ -7063,15 +7029,13 @@
<div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="galleryalt" src="http://example.com/images/3/3a/Foobar.jpg" width="120" height="14" /></a></div></div>
<div class="gallerytext">
<p><a href="/wiki/File:Foobar.jpg" class="image" title="desc"><img alt="inneralt" src="http://example.com/images/3/3a/Foobar.jpg" width="20" height="2" /></a>
-</p>
- </div>
+ </p></div>
</div></li>
<li class="gallerybox" style="width: 155px"><div style="width: 155px">
<div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="galleryalt" src="http://example.com/images/3/3a/Foobar.jpg" width="120" height="14" /></a></div></div>
<div class="gallerytext">
<p>This is a test template
-</p>
- </div>
+ </p></div>
</div></li>
</ul>
@@ -7093,30 +7057,26 @@
<div class="gallerytext">
<p><a href="/wiki/File:Nonexistant.jpg" title="File:Nonexistant.jpg">Nonexistant.jpg</a><br />
caption
-</p>
- </div>
+ </p></div>
</div></li>
<li class="gallerybox" style="width: 155px"><div style="width: 155px">
<div style="height: 150px;">Nonexistant.jpg</div>
<div class="gallerytext">
<p><a href="/wiki/File:Nonexistant.jpg" title="File:Nonexistant.jpg">Nonexistant.jpg</a><br />
-</p>
- </div>
+</p> </div>
</div></li>
<li class="gallerybox" style="width: 155px"><div style="width: 155px">
<div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="120" height="14" /></a></div></div>
<div class="gallerytext">
<p><a href="/wiki/File:Foobar.jpg" title="File:Foobar.jpg">Foobar.jpg</a><br />
some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
-</p>
- </div>
+ </p></div>
</div></li>
<li class="gallerybox" style="width: 155px"><div style="width: 155px">
<div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="120" height="14" /></a></div></div>
<div class="gallerytext">
<p><a href="/wiki/File:Foobar.jpg" title="File:Foobar.jpg">Foobar.jpg</a><br />
-</p>
- </div>
+</p> </div>
</div></li>
</ul>
@@ -7190,8 +7150,7 @@
__NEWSECTIONLINK__
__FORCETOC__
!! result
-<p><br />
-</p>
+<p><br /></p>
!! end
!! test
@@ -7669,14 +7628,16 @@
baz
!! result
<blockquote>
-foo
-</blockquote>
+<p>foo
+</p></blockquote>
<p>bar
-</p>
-<pre>baz
+</p><pre>baz
</pre>
!! end
+-------
+-------
+
!! test
Bug 8293: Use of center tag ruins paragraph formatting
!! input
@@ -7690,11 +7651,9 @@
!! result
<center>
<p>foo
-</p>
-</center>
+</p></center>
<p>bar
-</p>
-<pre>baz
+</p><pre>baz
</pre>
!! end
@@ -8006,8 +7965,7 @@
y
!! result
<p>x
-</p>
-<table>
+</p><table>
<tr>
<td> 1 </td>
<td> 2
@@ -8082,8 +8040,7 @@
==heading==
!! result
<p>[[link
-</p>
-<h2><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: heading">edit</a>]</span> <span class="mw-headline" id="heading">heading</span></h2>
+</p><h2><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: heading">edit</a>]</span> <span class="mw-headline" id="heading">heading</span></h2>
!! end
@@ -8094,8 +8051,7 @@
=heading=
!! result
<p>{{foo|
-</p>
-<h1> <span class="mw-headline" id="heading">heading</span></h1>
+</p><h1> <span class="mw-headline" id="heading">heading</span></h1>
!! end
@@ -8106,8 +8062,7 @@
==heading==
!! result
<p>{{foo|
-</p>
-<h2><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: heading">edit</a>]</span> <span class="mw-headline" id="heading">heading</span></h2>
+</p><h2><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: heading">edit</a>]</span> <span class="mw-headline" id="heading">heading</span></h2>
!! end
@@ -8129,7 +8084,7 @@
Line two</div>
!! result
<div>Line one
-Line two</div>
+<p>Line two</p></div>
!! end
@@ -8143,8 +8098,7 @@
!! result
<div>
<p>Line one
-</p>
-Line two</div>
+</p><p>Line two</p></div>
!! end
@@ -8158,8 +8112,7 @@
!! result
<div>Line one
<p>Line two
-</p>
-</div>
+</p></div>
!! end
@@ -8175,8 +8128,7 @@
<div>
<p>Line one
</p><p>Line two
-</p>
-</div>
+</p></div>
!! end
@@ -8197,11 +8149,8 @@
# 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
-
Line two</blockquote>
!! result
<blockquote>Line one
@@ -8211,8 +8160,6 @@
!! test
Bug 6200: paragraphs inside blockquotes (extra line break on open)
-!! options
-disabled
!! input
<blockquote>
Line one
@@ -8221,15 +8168,12 @@
!! result
<blockquote>
<p>Line one
-</p>
-Line two</blockquote>
+</p><p>Line two</p></blockquote>
!! end
!! test
Bug 6200: paragraphs inside blockquotes (extra line break on close)
-!! options
-disabled
!! input
<blockquote>Line one
@@ -8238,15 +8182,12 @@
!! result
<blockquote>Line one
<p>Line two
-</p>
-</blockquote>
+</p></blockquote>
!! end
!! test
Bug 6200: paragraphs inside blockquotes (extra line break on open and close)
-!! options
-disabled
!! input
<blockquote>
Line one
@@ -8257,8 +8198,7 @@
<blockquote>
<p>Line one
</p><p>Line two
-</p>
-</blockquote>
+</p></blockquote>
!! end
@@ -8270,7 +8210,7 @@
Line two</div></blockquote>
!! result
<blockquote><div>Line one
-Line two</div></blockquote>
+<p>Line two</p></div></blockquote>
!! end
@@ -8284,8 +8224,7 @@
!! result
<blockquote><div>
<p>Line one
-</p>
-Line two</div></blockquote>
+</p><p>Line two</p></div></blockquote>
!! end
@@ -8299,8 +8238,7 @@
!! result
<blockquote><div>Line one
<p>Line two
-</p>
-</div></blockquote>
+</p></div></blockquote>
!! end
@@ -8316,8 +8254,7 @@
<blockquote><div>
<p>Line one
</p><p>Line two
-</p>
-</div></blockquote>
+</p></div></blockquote>
!! end
@@ -8774,8 +8711,7 @@
<p data-abc-def_hij="">Quuz</p>
!! result
<p><span data-foo="bar">Baz</span>
-</p>
-<p data-abc-def_hij="">Quuz</p>
+</p><p data-abc-def_hij="">Quuz</p>
!! end
Index: includes/parser/Parser.php
===================================================================
--- includes/parser/Parser.php (revision 105869)
+++ includes/parser/Parser.php (working copy)
@@ -2030,7 +2030,7 @@
* @return Boolean
*/
function areSubpagesAllowed() {
- # Some namespaces don't allow subpages
+ // Some namespaces don't allow subpages
return MWNamespace::hasSubpages( $this->mTitle->getNamespace() );
}
@@ -2055,7 +2055,7 @@
function closeParagraph() {
$result = '';
if ( $this->mLastSection != '' ) {
- $result = '</' . $this->mLastSection . ">\n";
+ $result = '</' . $this->mLastSection . ">";
}
$this->mInPre = false;
$this->mLastSection = '';
@@ -2185,16 +2185,69 @@
$textLines = StringUtils::explode( "\n", $text );
$lastPrefix = $output = '';
- $this->mDTopen = $inBlockElem = false;
+ $this->mDTopen = false;
$prefixLength = 0;
- $paragraphStack = false;
+ // 0 = always start paragraph for a piece of text or inline tag
+ // 1 = some text of current paragraph already printed inline,
+ // so persist 1 across newline and print text from there inline also
+ // 2 = print text inline if there is some, but reset to 0 at newline if not
+ $dontStartParagraph = 0;
+
+ // the output position of last paragraph start
+ $lastParagraphPos = NULL;
+
+ // 'p' = inside a paragraph
+ // 'div' = inside a <div class="paragraph">
+ // 'pre' = inside preformatted lines (with space at beginning)
+ $this->mLastSection = '';
+
+ // true = inside a <pre> tag
+ $this->mInPre = false;
+
+ // > 0 = inside a $noPre tag
+ $inNoPre = 0;
+
+ // <div class="paragraph"> can itself contain paragraphs, so this is a stack of them
+ $nestedSections = array();
+
+ // empty lines counter
+ $emptyLines = 0;
+
+ // Block elements force to close current paragraph
+ $closesParagraph = array(
+ 'div' => 1,
+ 'center' => 1,
+ 'table' => 1,
+ 'caption' => 1,
+ 'tr' => 1,
+ 'td' => 1,
+ 'th' => 1,
+ 'h1' => 1,
+ 'h2' => 1,
+ 'h3' => 1,
+ 'h4' => 1,
+ 'h5' => 1,
+ 'h6' => 1,
+ 'hr' => 1,
+ 'ul' => 1,
+ 'ol' => 1,
+ 'li' => 1,
+ 'pre' => 1,
+ 'p' => 1,
+ 'blockquote' => 1,
+ 'script' => 1,
+ );
+
+ // These elements disallow preformatting by adding space at the beginning of line
+ $noPre = array(
+ 'table' => 1,
+ 'pre' => 1,
+ );
+
foreach ( $textLines as $oLine ) {
- # Fix up $linestart
if ( !$linestart ) {
- $output .= $oLine;
- $linestart = true;
- continue;
+ $dontStartParagraph = 1;
}
# * = ul
# # = ol
@@ -2202,11 +2255,9 @@
# : = dd
$lastPrefixLength = strlen( $lastPrefix );
- $preCloseMatch = preg_match( '/<\\/pre/i', $oLine );
- $preOpenMatch = preg_match( '/<pre/i', $oLine );
- # If not in a <pre> element, scan for and figure out what prefixes are there.
- if ( !$this->mInPre ) {
- # Multiple prefixes may abut each other for nested lists.
+ // If at line start and not in a <pre> element, scan for and figure out what prefixes are there.
+ if ( $linestart && !$this->mInPre ) {
+ // Multiple prefixes may abut each other for nested lists.
$prefixLength = strspn( $oLine, '*#:;' );
$prefix = substr( $oLine, 0, $prefixLength );
@@ -2216,7 +2267,6 @@
# elements.
$prefix2 = str_replace( ';', ':', $prefix );
$t = substr( $oLine, $prefixLength );
- $this->mInPre = (bool)$preOpenMatch;
} else {
# Don't interpret any other prefixes in preformatted text
$prefixLength = 0;
@@ -2227,8 +2277,9 @@
# List generation
if ( $prefixLength && $lastPrefix === $prefix2 ) {
# Same as the last item, so no need to deal with nesting or opening stuff
+ $output .= $this->closeParagraph();
+ $dontStartParagraph = 2;
$output .= $this->nextItem( substr( $prefix, -1 ) );
- $paragraphStack = false;
if ( substr( $prefix, -1 ) === ';') {
# The one nasty exception: definition lists work like this:
@@ -2241,12 +2292,17 @@
$output .= $term . $this->nextItem( ':' );
}
}
+
+ // Reset linestart to false to ignore heading space
+ $linestart = false;
+ $emptyLines = 0;
} elseif ( $prefixLength || $lastPrefixLength ) {
+ $output .= $this->closeParagraph();
+ $dontStartParagraph = $prefixLength ? 2 : 0;
# We need to open or close prefixes, or both.
# Either open or close a level...
$commonPrefixLength = $this->getCommon( $prefix, $lastPrefix );
- $paragraphStack = false;
# Close all the prefixes which aren't shared.
while ( $commonPrefixLength < $lastPrefixLength ) {
@@ -2274,71 +2330,148 @@
++$commonPrefixLength;
}
$lastPrefix = $prefix2;
+
+ // Reset linestart to false to ignore heading space
+ $linestart = !$prefixLength;
+ $emptyLines = 0;
}
- # If we have no prefixes, go to paragraph mode.
- if ( 0 == $prefixLength ) {
- 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|<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|<\\/?center)/iS', $t );
- if ( $openmatch or $closematch ) {
- $paragraphStack = false;
- # TODO bug 5718: paragraph closed
- $output .= $this->closeParagraph();
- if ( $preOpenMatch and !$preCloseMatch ) {
- $this->mInPre = true;
- }
- $inBlockElem = !$closematch;
- } elseif ( !$inBlockElem && !$this->mInPre ) {
- if ( ' ' == substr( $t, 0, 1 ) and ( $this->mLastSection === 'pre' || trim( $t ) != '' ) ) {
- # pre
- if ( $this->mLastSection !== 'pre' ) {
- $paragraphStack = false;
- $output .= $this->closeParagraph().'<pre>';
- $this->mLastSection = 'pre';
+ // Go to paragraph mode.
+ wfProfileIn( __METHOD__."-paragraph" );
+ if ( $linestart && $inNoPre <= 0 && ' ' == substr( $t, 0, 1 ) &&
+ ( $this->mLastSection === 'pre' || trim( $t ) != '' ) ) {
+ // <pre>formatted text
+ $emptyLines = 0;
+ if ( $this->mLastSection !== 'pre' ) {
+ $output .= $this->closeParagraph().'<pre>';
+ $this->mLastSection = 'pre';
+ }
+ $output .= substr( $t, 1 ) . "\n";
+ } elseif ( !$this->mInPre && trim( $t ) === '' ) {
+ // close paragraph
+ $output .= $this->closeParagraph();
+ $dontStartParagraph = 0;
+ $emptyLines++;
+ if ( $emptyLines > 1 ) {
+ // start a new paragraph
+ $lastParagraphPos = strlen( $output );
+ $this->mLastSection = 'p';
+ $output .= '<p><br />';
+ $emptyLines = 0;
+ }
+ } else {
+ $emptyLines = 0;
+ while ( strlen( $t ) ) {
+ // match html tag or preformatted block hidden by link holder
+ // <html> does not influence on paragraphs in any way, so we don't match it
+ if ( preg_match('/<(\/?)([a-z][a-z0-9]*).*?(\/?)>|('.$this->mUniqPrefix.
+ '-pre.*?'.self::MARKER_SUFFIX.')/iS', $t, $m, PREG_OFFSET_CAPTURE ) ) {
+ $textBefore = substr( $t, 0, $m[0][1] );
+ $t = substr( $t, $m[0][1] + strlen( $m[0][0] ) );
+ if ( $m[2][0] && !$closesParagraph[ $m[2][0] ] ) {
+ $textBefore .= $m[0][0];
+ $m[0][0] = '';
}
- $t = substr( $t, 1 );
} else {
- # paragraph
- if ( trim( $t ) === '' ) {
- if ( $paragraphStack ) {
- $output .= $paragraphStack.'<br />';
- $paragraphStack = false;
- $this->mLastSection = 'p';
- } else {
- if ( $this->mLastSection !== 'p' ) {
+ $textBefore = $t;
+ $t = '';
+ }
+ $match = $m[0][0];
+ $close = $m[1][0];
+ $tag = $m[2][0];
+ $empty = $m[3][0];
+ $uniq = $m[4][0];
+ if ( $textBefore !== '' ) {
+ // Here is the place where the text gets inside <p>aragraphs
+ if ( trim( $textBefore ) !== '' ) {
+ if ( !$this->mInPre && !$dontStartParagraph ) {
+ if ( $this->mLastSection == 'pre' ) {
$output .= $this->closeParagraph();
- $this->mLastSection = '';
- $paragraphStack = '<p>';
- } else {
- $paragraphStack = '</p><p>';
}
+ if ( !$this->mLastSection && !$this->mInPre ) {
+ $lastParagraphPos = strlen( $output );
+ $output .= '<p>';
+ $this->mLastSection = 'p';
+ }
}
- } else {
- if ( $paragraphStack ) {
- $output .= $paragraphStack;
- $paragraphStack = false;
- $this->mLastSection = 'p';
- } elseif ( $this->mLastSection !== 'p' ) {
- $output .= $this->closeParagraph().'<p>';
- $this->mLastSection = 'p';
+ elseif ( $dontStartParagraph == 2 ) {
+ $dontStartParagraph = 1;
}
}
+ $output .= $textBefore;
}
+ if ( $this->mInPre && $close && $tag == 'pre' ) {
+ // this is </pre> closing tag
+ $this->mInPre = false;
+ $inNoPre--;
+ } elseif ( $uniq ) {
+ // UNIQ <pre> closes paragraph
+ $output .= $this->closeParagraph();
+ } elseif ( $closesParagraph[ $tag ] ) {
+ // block element closes current paragraph
+ if ( $tag != 'div' ) {
+ // <div> does not close the paragraph,
+ // but turns it into a <div class="paragraph">
+ $output .= $this->closeParagraph();
+ } elseif ( !$empty ) {
+ // <div> is the only case of nested "paragraphs"
+ if ( $close ) {
+ // </div> - close current nesting level
+ $output .= $this->closeParagraph();
+ list( $this->mLastSection, $inNoPre ) = array_pop( $nestedSections );
+ } else {
+ // <div> - start a nested level
+ if ( $this->mLastSection == 'p' && $tag == 'div' ) {
+ // <div> can not be used inside <p>
+ // so turn last <p> into a <div class="paragraph">
+ $output =
+ substr( $output, 0, $lastParagraphPos ) .
+ '<div class="paragraph">' .
+ substr( $output, $lastParagraphPos+3 );
+ $this->mLastSection = 'div';
+ }
+ $nestedSections[] = array( $this->mLastSection, $inNoPre );
+ $this->mLastSection = '';
+ $inNoPre = 0;
+ }
+ }
+ // if not an enclosed XML element
+ if ( !$empty ) {
+ if ( $noPre[ $tag ] ) {
+ $inNoPre += $close ? -1 : 1;
+ }
+ if ( !$close ) {
+ if ( !$this->mLastSection ) {
+ // do not start paragraph right after opening block
+ // element tag on the same line. I.e. <div>A</div> is parsed
+ // into <div>A</div>, and <div>\nA</div> is parsed
+ // into <div><p>A</p></div>
+ $dontStartParagraph = 2;
+ }
+ if ( $tag == 'pre' && !$empty ) {
+ $this->mInPre = true;
+ }
+ } elseif ( $dontStartParagraph ) {
+ // Current block element is closed
+ $dontStartParagraph = 2;
+ }
+ }
+ }
+ if ( $match !== '' ) {
+ $output .= $match;
+ }
}
- wfProfileOut( __METHOD__."-paragraph" );
+ $output .= "\n";
+ // If line ended after opening block element tag with no text after it
+ // => allow to start a paragraph from next line
+ // If there was some text (dontStartParagraph == 1)
+ // => do not start a paragraph from next line
+ if ( $dontStartParagraph == 2 ) {
+ $dontStartParagraph = 0;
+ }
}
- # somewhere above we forget to get out of pre block (bug 785)
- if ( $preCloseMatch && $this->mInPre ) {
- $this->mInPre = false;
- }
- if ( $paragraphStack === false ) {
- $output .= $t."\n";
- }
+ wfProfileOut( __METHOD__."-paragraph" );
+ $linestart = true;
}
while ( $prefixLength ) {
$output .= $this->closeList( $prefix2[$prefixLength-1] );

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2697
Default Alt Text
Parser-new-doblocklevels-r105865.diff (38 KB)

Event Timeline