*/
private $djVuSupport;
+ /**
+ * @var TidySupport
+ */
+ private $tidySupport;
+
private $maxFuzzTestLength = 300;
private $fuzzSeed = 0;
private $memoryLimit = 50;
$this->runParsoid = isset( $options['run-parsoid'] );
$this->djVuSupport = new DjVuSupport();
+ $this->tidySupport = new TidySupport();
+ if ( !$this->tidySupport->isEnabled() ) {
+ echo "Warning: tidy is not installed, skipping some tests\n";
+ }
$this->hooks = array();
$this->functionHooks = array();
$output = $parser->parse( $input, $title, $options, true, true, 1337 );
$output->setTOCEnabled( !isset( $opts['notoc'] ) );
$out = $output->getText();
+ if ( isset( $opts['tidy'] ) ) {
+ if ( !$this->tidySupport->isEnabled() ) {
+ return $this->showSkipped();
+ }
+ $out = MWTidy::tidy( $out );
+ $out = preg_replace( '/\s+$/', '', $out);
+ }
if ( isset( $opts['showtitle'] ) ) {
if ( $output->getTitleText() ) {
}
if ( isset( $opts['ill'] ) ) {
- $out = $this->tidy( implode( ' ', $output->getLanguageLinks() ) );
+ $out = implode( ' ', $output->getLanguageLinks() );
} elseif ( isset( $opts['cat'] ) ) {
$outputPage = $context->getOutput();
$outputPage->addCategoryLinks( $output->getCategories() );
$cats = $outputPage->getCategoryLinks();
if ( isset( $cats['normal'] ) ) {
- $out = $this->tidy( implode( ' ', $cats['normal'] ) );
+ $out = implode( ' ', $cats['normal'] );
} else {
$out = '';
}
}
-
- $result = $this->tidy( $result );
}
$this->teardownGlobals();
* @param string $config
*/
private function setupGlobals( $opts = '', $config = '' ) {
+ global $IP;
+
# Find out values for some special options.
$lang =
self::getOptionValue( 'language', $opts, 'en' );
'wgLocaltimezone' => 'UTC',
'wgAllowExternalImages' => self::getOptionValue( 'wgAllowExternalImages', $opts, true ),
'wgThumbLimits' => array( self::getOptionValue( 'thumbsize', $opts, 180 ) ),
- 'wgUseTidy' => false,
'wgDefaultLanguageVariant' => $variant,
'wgVariantArticlePath' => false,
'wgGroupPermissions' => array( '*' => array(
'wgLinkHolderBatchSize' => $linkHolderBatchSize,
'wgExperimentalHtmlIds' => false,
'wgExternalLinkTarget' => false,
- 'wgAlwaysUseTidy' => false,
'wgHtml5' => true,
'wgWellFormedXml' => true,
'wgAllowMicrodataAttributes' => true,
'wgAdaptiveMessageCache' => true,
'wgDisableLangConversion' => false,
'wgDisableTitleConversion' => false,
+ // Tidy options.
+ // We always set 'wgUseTidy' to false when parsing, but certain
+ // test-running modes still use tidy if available, so ensure
+ // that the tidy-related options are all set to their defaults.
+ 'wgUseTidy' => false,
+ 'wgAlwaysUseTidy' => false,
+ 'wgDebugTidy' => false,
+ 'wgTidyConf' => $IP . '/includes/tidy.conf',
+ 'wgTidyOpts' => '',
+ 'wgTidyInternal' => $this->tidySupport->isInternal(),
);
if ( $config ) {
return true;
}
- /**
- * Run the "tidy" command on text if the $wgUseTidy
- * global is true
- *
- * @param string $text The text to tidy
- * @return string
- */
- private function tidy( $text ) {
- global $wgUseTidy;
-
- if ( $wgUseTidy ) {
- $text = MWTidy::tidy( $text );
- }
-
- return $text;
- }
-
private function wellFormed( $text ) {
$html =
Sanitizer::hackDocType() .
blah blah
!! endarticle
+!!article
+Foo
+!!text
+FOO
+!!endarticle
+
!!article
Template:Foo
!!text
</p>
!! end
+# Note that the html+tidy output removes the spaces after the <li>,
+# which is a bug (http://sourceforge.net/p/tidy/bugs/945/, etc).
+# This is an issue for all tests with lists. We intentionally do
+# *not* add html+tidy clauses for these, as we don't want to
+# document/test the broken behavior. (Parsoid matches the non-tidy
+# output in these cases.)
+
!! test
Simple list
!! wikitext
parsoid=wt2wt,html2wt
!! wikitext
'''''foo'''''
-!! html/*
+!! html
<p><b><i>foo</i></b>
</p>
!! end
!''a!!''b
|''a||''b
|}
-!! html
+!! html/php+tidy
+<table>
+<tr>
+<th><i>a</i></th>
+<th><i>b</i></th>
+<td><i>a</i></td>
+<td><i>b</i></td>
+</tr>
+</table>
+!! html/parsoid
<table>
<tbody><tr><th><i>a</i></th><th><i>b</i></th>
<td><i>a</i></td><td><i>b</i></td></tr>
</p>
!! end
+# There is a tidy bug here: http://sourceforge.net/p/tidy/bugs/946/
!! test
Non-word characters don't terminate tag names (bug 17663, 40670, 52022)
!! wikitext
a <div>foo</div>
<p>b
</p>
+!! html+tidy
+<p>a</p>
+<div>foo</div>
+<p>b</p>
!! end
!! test
a <blockquote>foo</blockquote>
<p>b
</p>
+!! html+tidy
+<p>a</p>
+<blockquote>
+<p>foo</p>
+</blockquote>
+<p>b</p>
!! end
!! test
a <div>foo</div>
b <div>foo</div>
+!! html+tidy
+<p>a</p>
+<div>foo</div>
+<p>b</p>
+<div>foo</div>
!! end
!! test
a <blockquote>foo</blockquote>
b <blockquote>foo</blockquote>
+!! html+tidy
+<p>a</p>
+<blockquote>
+<p>foo</p>
+</blockquote>
+<p>b</p>
+<blockquote>
+<p>foo</p>
+</blockquote>
!! end
!! test
</p>
x <div>foo</div> z
+!! html+tidy
+<div>foo</div>
+<p>a</p>
+<p>b c d e</p>
+<p>x</p>
+<div>foo</div>
+<p>z</p>
!! end
!! test
</p>
<div>e</div>
+!! html+tidy
+<p><br /></p>
+<p>a</p>
+<p>b</p>
+<div>a</div>
+<p>b</p>
+<div>b</div>
+<p>d</p>
+<p><br /></p>
+<div>e</div>
!! end
## PHP parser emits output which is broken
+## XXX The parsoid output doesn't match the tidy output.
!! test
Unclosed HTML p-tags should be handled properly
!! wikitext
a
b
+!! html/php+tidy
+<div>
+<p>foo</div></p>
+<p>a</p>
+b</div>
!! html/parsoid
<div data-parsoid='{"stx":"html"}'><p data-parsoid='{"stx":"html", "autoInsertedEnd":true}'>foo</p></div>
<p>a</p>
<blockquote>Foo <del>bar</del> <ins>baz</ins> quux
</blockquote>
+!! html+tidy
+<blockquote>
+<p>Foo</p>
+<del>bar</del> <ins>baz</ins> quux</blockquote>
!! end
!! test
</pre></div>
<pre></pre>
+!! html+tidy
+<p>a</p>
+<div>
+<pre>
+foo
+</pre></div>
!! end
!! test
a
| b
| c
-!! html/parsoid
+!! html/php
<pre>a
| b
-| c</pre>
+| c
+</pre>
!!end
!!test
a
| b
| c
+!! html/php
+<p>a
+</p>
+<pre>| b
+| c
+</pre>
!! html/parsoid
<p>a</p>
<pre>
c <blockquote> foo </blockquote>
<pre><span> foo </span>
</pre>
-!!end
+!! html+tidy
+<p>a</p>
+<p>foo</p>
+<p>b</p>
+<div>foo</div>
+<p>c</p>
+<blockquote>
+<p>foo</p>
+</blockquote>
+<pre>
+<span> foo </span>
+</pre>
+!! end
!!test
3b. Indent-Pre and block tags (multi-line html)
</pre>
b <div> foo </div>
+!! html+tidy
+<pre>
+a <span>foo</span>
+</pre>
+<p>b</p>
+<div>foo</div>
!!end
!!test
</div></li>
</ul>
+!! html+tidy
+<p>a</p>
+<ul class="gallery mw-gallery-traditional">
+<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/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" /></a></div>
+</div>
+<div class="gallerytext"></div>
+</div>
+</li>
+</ul>
!!end
!! test
## The Parsoid team believes the following three test exposes a
## bug in the PHP parser. (Parsoid team thinks the PHP parser is
## wrong to close the <dl> after the <dt> containing the <ul>.)
+## It also exposes a "misfeature" in tidy, which doesn't like
+## <dl> tags with a single <dt> child; it converts the <dt> into
+## a <dd> in that case. (Parsoid leaves the <dt> alone!)
!! test
Definition Lists: Mixed Lists: Test 1
!! wikitext
<li> bar</li></ul></dt></dl>
<dl><dt> baz</dt></dl></dd></dl>
+!! html/php+tidy
+<dl>
+<dd>
+<dl>
+<dd>
+<ul>
+<li>foo</li>
+<li>bar</li>
+</ul>
+</dd>
+</dl>
+<dl>
+<dt>baz</dt>
+</dl>
+</dd>
+</dl>
!! html/parsoid
<dl>
<dd><dl>
# rules regarding dd/dt on the next two tests. Parsoid is more
# consistent, and recognizes the shared nesting and keeps the
# still-open tags around until the nesting is complete.
+# (And tidy again converts <dt> to <dd> before 'bar'.)
!! test
Definition Lists: Mixed Lists: Test 11
<dl><dt>boo </dt>
<dd>baz</dd></dl></li></ol></li></ul></li></ol></li></ul>
+!! html/php+tidy
+<ul>
+<li>
+<ol>
+<li>
+<ul>
+<li>
+<ol>
+<li>
+<dl>
+<dt>foo </dt>
+<dd>
+<ul>
+<li>
+<dl>
+<dd>
+<dl>
+<dt>bar</dt>
+</dl>
+</dd>
+</dl>
+</li>
+</ul>
+</dd>
+</dl>
+<dl>
+<dt>boo </dt>
+<dd>baz</dd>
+</dl>
+</li>
+</ol>
+</li>
+</ul>
+</li>
+</ol>
+</li>
+</ul>
!! html/parsoid
<ul>
<li>
!! end
+# Another case where tidy converts a <dt> to a <dd> (but Parsoid doesn't).
!! test
Definition Lists: Weird Ones: Test 1
!! wikitext
<ul><li><ol><li><dl><dt> foo </dt>
<dd><ul><li><dl><dd><dl><dd><dl><dt><dl><dt> bar (who uses this?)</dt></dl></dd></dl></dd></dl></dd></dl></li></ul></dd></dl></li></ol></li></ul>
+!! html/php+tidy
+<ul>
+<li>
+<ol>
+<li>
+<dl>
+<dt>foo </dt>
+<dd>
+<ul>
+<li>
+<dl>
+<dd>
+<dl>
+<dd>
+<dl>
+<dd>
+<dl>
+<dt>bar (who uses this?)</dt>
+</dl>
+</dd>
+</dl>
+</dd>
+</dl>
+</dd>
+</dl>
+</li>
+</ul>
+</dd>
+</dl>
+</li>
+</ol>
+</li>
+</ul>
!! html/parsoid
<ul>
<li>
[[wikipedia:Foo|Bar]]
[[wikipedia:Foo|<span>Bar</span>]]
+!! html/php
+<p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/wiki/Foo">[1]</a>
+</p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a>
+</p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo"><span>Bar</span></a>
+</p>
!! html/parsoid
<p><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo"></a></p>
<p><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo">Bar</a></p>
!! html/php
<p><a rel="nofollow" class="external text" href="http://www.musee-picasso.fr/pages/page_id18528_u1l2.htm"><i>La muerte de Casagemas</i> (1901) en el sitio de <a href="/index.php?title=Museo_Picasso_(Par%C3%ADs)&action=edit&redlink=1" class="new" title="Museo Picasso (París) (page does not exist)">Museo Picasso</a>.</a>
</p>
+!! html/php+tidy
+<p><a rel="nofollow" class="external text" href="http://www.musee-picasso.fr/pages/page_id18528_u1l2.htm"><i>La muerte de Casagemas</i> (1901) en el sitio de</a> <a href="/index.php?title=Museo_Picasso_(Par%C3%ADs)&action=edit&redlink=1" class="new" title="Museo Picasso (París) (page does not exist)">Museo Picasso</a>.</p>
!! html/parsoid
<p><a rel="mw:ExtLink" href="http://www.musee-picasso.fr/pages/page_id18528_u1l2.htm"><i>La muerte de Casagemas</i> (1901) en el sitio de </a><a rel="mw:WikiLink" href="./Museo_Picasso_(París)">Museo Picasso</a><span>.</span></p>
!! end
{|
| Foo!! ||
|}
+!! html
+<table>
+<tr>
+<td> Foo!! </td>
+<td>
+</td></tr></table>
+
!! html/parsoid
<table data-parsoid='{}'>
<tbody data-parsoid='{}'><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'> Foo!! </td><td data-parsoid='{"stx_v":"row","autoInsertedEnd":true}'></td></tr>
<!--c1-->
<!--c2-->| b
|}
+!! html
+<table>
+<tr>
+<td>a
+</td>
+<td> b
+</td></tr></table>
+
!! html/parsoid
<table>
<tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>a</td>
<td>foo</td></tr></tbody></table>
!! end
+## Note that Parsoid output differs from PHP and PHP+tidy here.
+## The lack of <tr> tags in the PHP output is arguably a bug in the
+## PHP parser, which tidy then compounds by fostering the content
+## entirely out of the table. Parsoid recognizes the table context
+## and generates <tr> and <td> wrappers as needed. Hopefully nobody
+## depends on PHP's treatment of broken table markup!
!! test
Implicit <td> after a |-
-(PHP parser relies on Tidy to add the missing <td> tags)
!! options
parsoid=wt2html,wt2wt
!! wikitext
|-
a
|}
-!! html
+!! html/php
+<table>
+
+a
+</table>
+
+!! html/php+tidy
+<p>a</p>
+!! html/parsoid
<table>
<tr><td>a</td></tr>
</table>
!! end
+# Again, Parsoid adds implicit <td>s here, PHP and Tidy strip the b out.
!! test
-Pres should be recognized in an explicit <td> context, but not in an implicit <td> context
-(PHP parser relies on Tidy to add the missing <td> tags)
+<pre> tags should be recognized in an explicit <td> context, but not in an implicit <td> context
!! options
parsoid=wt2html,wt2wt
!! wikitext
|-
b
|}
-!! html
+!! html/php
+<table>
+
+<tr>
+<td>
+<pre>a
+</pre>
+</td></tr>
+ b
+</table>
+
+!! html/php+tidy
+<p>b</p>
+<table>
+<tr>
+<td>
+<pre>
+a
+</pre></td>
+</tr>
+</table>
+!! html/parsoid
<table>
<tbody>
<tr><td><pre>a</pre></td></tr>
</table>
!! end
+# PHP + Tidy strips the list out of the table; Parsoid wraps it.
!! test
Lists should be recognized in an implicit <td> context
-(PHP parser relies on Tidy to add the missing <td> tags)
!! options
parsoid=wt2html,wt2wt
!! wikitext
|-
*a
|}
-!! html
+!! html/php
+<table>
+
+<ul><li>a</li></ul>
+</table>
+
+!! html/php+tidy
+<ul>
+<li>a</li>
+</ul>
+!! html/parsoid
<table>
<tr>
<td><ul>
! foo || bar
<!-- foo --> || baz || quux
|}
+!! html/php
+<table>
+<tr>
+<th> foo </th>
+<th> bar
+</th>
+<td> baz </td>
+<td> quux
+</td></tr></table>
+
!! html/parsoid
<table>
-<tbody>
-<tr><th>foo </th><th>bar </th>
-<td>baz </td>
-<td>quux</td></tr></tbody></table>
+<tbody><tr><th> foo </th><th> bar
+<!-- foo --> </th><td> baz </td><td> quux</td></tr>
+</tbody></table>
!! end
+# PHP throws away the (semi-broken) "foo" class here; Parsoid
+# preserves it.
!!test
Parsoid: Recover better from broken table attributes
!!options
| class="bar" |
foo
|}
+!!html/php+tidy
+<table>
+<tr>
+<td class="bar">
+<p>foo</p>
+</td>
+</tr>
+</table>
!!html/parsoid
<table class="foo">
<tr>
!! html/php
<p><strong class="selflink">Bug462</strong> <strong class="selflink">Bug462</strong>
</p>
+!! html/php+tidy
+<p><strong class="selflink">Bug462</strong> <strong class="selflink">Bug462</strong></p>
!! html/parsoid
<p><a rel="mw:WikiLink" href="./Bug462">Bug462</a> <a rel="mw:WikiLink" href="./Bug462">Bug462</a></p>
!! end
title=[[User:test/123]]
!! wikitext
[[#a|b]]
+!! html/php
+<p><a href="#a">b</a>
+</p>
!! html/parsoid
<p data-parsoid='{}'><a rel="mw:WikiLink" href="../User:Test/123#a" data-parsoid='{"stx":"piped","a":{"href":"../User:Test/123#a"},"sa":{"href":"#a"}}'>b</a></p>
!! end
[http://wp.org ''foo'']
!! html
-<p><a href="/index.php?title=Foo&action=edit&redlink=1" class="new" title="Foo (page does not exist)"> bar</a>
-</p><p><a href="/index.php?title=Foo&action=edit&redlink=1" class="new" title="Foo (page does not exist)"> <i>bar</i></a>
+<p><a href="/wiki/Foo" title="Foo"> bar</a>
+</p><p><a href="/wiki/Foo" title="Foo"> <i>bar</i></a>
</p><p><a rel="nofollow" class="external text" href="http://wp.org">foo</a>
</p><p><a rel="nofollow" class="external text" href="http://wp.org"><i>foo</i></a>
</p>
Link with angle bracket after anchor
!! wikitext
[[Foo#<bar>]]
+!! html/php
+<p><a href="/wiki/Foo#.3Cbar.3E" title="Foo">Foo#<bar></a>
+</p>
!! html/parsoid
<p><a rel="mw:WikiLink" href="./Foo#%3Cbar%3E" data-parsoid='{"stx":"simple","a":{"href":"./Foo#%3Cbar%3E"},"sa":{"href":"Foo#<bar>"}}'>Foo#<bar></a></p>
!! end
<ul><li><a href="http://en.wikipedia.org/wiki/ro:Olteni%C5%A3a" class="extiw" title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteniţa</a></li>
<li><a href="http://en.wikipedia.org/wiki/ro:Olteni%C5%A3a" class="extiw" title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteniţa</a></li></ul>
+!! html+tidy
+<ul>
+<li><a href="http://en.wikipedia.org/wiki/ro:Olteni%C5%A3a" class="extiw" title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteniţa</a></li>
+<li><a href="http://en.wikipedia.org/wiki/ro:Olteni%C5%A3a" class="extiw" title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteniţa</a></li>
+</ul>
!! end
!! test
!! end
# TODO: Fix html2html mode (bug 51055)!
+# This </br> handling was added as part of bug 50831; but it
+# differs from how PHP+tidy handles this. We should investigate
+# this.
!! test
Parsoid: Broken br tag recognition
!! options
</br>
<br/ >
+!! html/php+tidy
+<p></br></p>
+<p><br /></p>
!! html/parsoid
<p><br></p>
<p><br/></p>
!! html
<hr /> Foo
+!! html+tidy
+<hr />
+<p>Foo</p>
!! end
###
</li>
</li>
+!! html+tidy
+<ul>
+<li>a</li>
+<li>b</li>
+<li>c</li>
+</ul>
!!end
!!test
!!test
Test the li-hack
-(Cannot test this with PHP parser since it relies on Tidy for the hack)
+(The PHP parser relies on Tidy for the hack)
!!options
parsoid=wt2html,wt2wt
!! wikitext
<li><li>not a li-hack
</li>
</ul>
-!! html
+!! html+tidy
<ul>
-<li> foo</li>
+<li>foo</li>
<li>li-hack</li>
-<li about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<li>templated li-hack"}}}}]}'>templated li-hack</li>
-<li> <!--foo--> </li>
-<li> li-hack with preceding comments</li>
+<li>templated li-hack</li>
+<li>unsupported li-hack with preceding comments</li>
</ul>
-
<ul>
-<li></li>
-<li>not a li-hack
-</li>
+<li>not a li-hack</li>
</ul>
!!end
!! test
Unbalanced closing block tags break a list
-(Parsoid-only since php parser generates broken html -- relies on Tidy to fix up)
+(php parser relies on Tidy to fix up)
!! wikitext
<div>
*a</div><div>
*b</div>
-!! html/parsoid
+!! html+tidy
<div>
<ul>
-<li>a
-</li>
-</ul></div><div>
+<li>a</li>
+</ul>
+</div>
+<div>
<ul>
-<li>b
-</li>
-</ul></div>
+<li>b</li>
+</ul>
+</div>
!! end
+# Parsoid fails this test, but it might be tricky to support properly.
+# See bug 68395.
!! test
Unbalanced closing non-block tags don't break a list
-(Parsoid-only since php parser generates broken html -- relies on Tidy to fix up)
+(php parser relies on Tidy to fix up)
!! wikitext
<span>
*a</span><span>
*b</span>
+!! html/php+tidy
+<ul>
+<li><span>a</span></li>
+<li><span>b</span></li>
+</ul>
!! html/parsoid
-<p><span></span>
-</p>
+<span>
<ul>
<li>a<span></span>
</li>
<li>b
</li>
</ul>
+</span>
!! end
!! test
Unclosed formatting tags that straddle lists are closed and reopened
-(Parsoid-only since php parser generates broken html -- relies on Tidy to fix up)
+(php parser relies on Tidy to fix up)
!! wikitext
# <s> a
# b </s>
+!! html/php+tidy
+<ol>
+<li><s>a</s></li>
+<li><s>b</s></li>
+</ol>
!! html/parsoid
<ol>
<li> <s> a </s>
</ol>
!! end
+# Parsoid fails this test, but it might be tricky to support properly.
+# See bug 68395.
!!test
List embedded in a non-block tag
-(Ugly Parsoid output -- worth fixing; Disabled for PHP parser since it relies on Tidy)
+(Ugly Parsoid output -- worth fixing; PHP parser relies on Tidy)
!! wikitext
<small>
* foo
</small>
+!! html/php+tidy
+<ul>
+<li><small>foo</small></li>
+</ul>
!! html/parsoid
-<p><small></small></p>
<small>
<ul>
<li> foo</li>
</ul>
</small>
-<p><small></small></p>
!!end
+# This is a bug in the PHP parser + tidy combination.
+# (The </tr> tag gets parsed as text and html-escaped by PHP,
+# and then fostered out of the table by tidy.)
+# We believe the Parsoid output to be correct.
!! test
Table with missing opening <tr> tag
!! options
<td>foo</td>
</tr>
</table>
+!! html/php+tidy
+<p></tr></p>
+<table>
+<tr>
+<td>foo</td>
+</tr>
+</table>
!! html/parsoid
<table>
<tr>
title=[['foo & bar = baz']]
!! wikitext
''{{PAGENAME}}''
-!! html
+!! html/php
<p><i>'foo & bar = baz'</i>
</p>
+!! html+tidy
+<p><i>'foo & bar = baz'</i></p>
!! end
!! test
title=[[*RFC 1234 http://example.com/]]
!! wikitext
{{PAGENAME}}
-!! html
+!! html/php
<p>*RFC 1234 http://example.com/
</p>
+!! html+tidy
+<p>*RFC 1234 http://example.com/</p>
!! end
!! test
title=[[*RFC 1234 http://example.com/]]
!! wikitext
{{PAGENAMEE}}
-!! html
+!! html/php
<p>*RFC_1234_http://example.com/
</p>
+!! html+tidy
+<p>*RFC_1234_http://example.com/</p>
!! end
!! test
!! wikitext
{{paramtest|
param =[[Image:noimage.png|thumb|[[no link|link]] [[no link|caption]]]]}}
-!! html
+!! html/php
This is a test template with parameter <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/index.php?title=Special:Upload&wpDestFile=Noimage.png" class="new" title="File:Noimage.png">File:Noimage.png</a> <div class="thumbcaption"><a href="/index.php?title=No_link&action=edit&redlink=1" class="new" title="No link (page does not exist)">link</a> <a href="/index.php?title=No_link&action=edit&redlink=1" class="new" title="No link (page does not exist)">caption</a></div></div></div>
+!! html+tidy
+<p>This is a test template with parameter</p>
+<div class="thumb tright">
+<div class="thumbinner" style="width:182px;"><a href="/index.php?title=Special:Upload&wpDestFile=Noimage.png" class="new" title="File:Noimage.png">File:Noimage.png</a>
+<div class="thumbcaption"><a href="/index.php?title=No_link&action=edit&redlink=1" class="new" title="No link (page does not exist)">link</a> <a href="/index.php?title=No_link&action=edit&redlink=1" class="new" title="No link (page does not exist)">caption</a></div>
+</div>
+</div>
!! end
!! article
{{{{echo|[[foo}}]]}}
!! html
-<p>{{<a href="/index.php?title=Foo&action=edit&redlink=1" class="new" title="Foo (page does not exist)">foo</a>}}
-</p><p>{{<a href="/index.php?title=Foo&action=edit&redlink=1" class="new" title="Foo (page does not exist)">foo</a>}}
+<p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
+</p><p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
</p><p>{{[[foo}}]]
</p>
!! end
<div>Foo</div>
<blockquote>Foo</blockquote>
+!! html+tidy
+<div>Foo</div>
+<blockquote>
+<p>Foo</p>
+</blockquote>
!!end
!!test
</p>
bar <div>baz</div>
-!!end
+!! html+tidy
+<p>Foo</p>
+<p>bar</p>
+<div>baz</div>
+!! end
!!test
Templates: P-wrapping: 1d. Template preceded by comment-only line
!! wikitext
{{echo|[[Foo|bar]]}}
!! html
-<p><a href="/index.php?title=Foo&action=edit&redlink=1" class="new" title="Foo (page does not exist)">bar</a>
+<p><a href="/wiki/Foo" title="Foo">bar</a>
</p>
!!end
!! wikitext
[[{{echo|Foo}}|bar]]
!! html
-<p><a href="/index.php?title=Foo&action=edit&redlink=1" class="new" title="Foo (page does not exist)">bar</a>
+<p><a href="/wiki/Foo" title="Foo">bar</a>
</p>
!!end
[[:Foo{{echo|bar}}|bar]]
!! html
-<p><a href="/index.php?title=Foo&action=edit&redlink=1" class="new" title="Foo (page does not exist)">bar</a>
+<p><a href="/wiki/Foo" title="Foo">bar</a>
</p><p><a href="/index.php?title=Foobar&action=edit&redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
</p><p><a href="/index.php?title=Foobarbaz&action=edit&redlink=1" class="new" title="Foobarbaz (page does not exist)">Foobarbaz</a>
</p><p><a href="/index.php?title=Foobar&action=edit&redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
!! wikitext
[[Foo|{{echo|bar}}]]
!! html
-<p><a href="/index.php?title=Foo&action=edit&redlink=1" class="new" title="Foo (page does not exist)">bar</a>
+<p><a href="/wiki/Foo" title="Foo">bar</a>
</p>
!!end
!! wikitext
{{echo|[[{{echo|Foo}}|bar]]}}
!! html
-<p><a href="/index.php?title=Foo&action=edit&redlink=1" class="new" title="Foo (page does not exist)">bar</a>
+<p><a href="/wiki/Foo" title="Foo">bar</a>
</p>
!!end
a
<tr><td></td></tr></table>
-!!end
+!! html+tidy
+<p>a</p>
+<table>
+<tr>
+<td></td>
+</tr>
+</table>
+!! end
!!test
Templates: Wiki Tables: 1b. Fostering of entire template content
</div>
<tr><td></td></tr></table>
-!!end
+!! html+tidy
+<div>
+<p>foo</p>
+</div>
+<table>
+<tr>
+<td></td>
+</tr>
+</table>
+!! end
!!test
Templates: Wiki Tables: 2. Fostering of partial template content
<div>b</div>
<tr><td></td></tr></table>
-!!end
+!! html+tidy
+<p>a</p>
+<div>b</div>
+<table>
+<tr>
+<td></td>
+</tr>
+</table>
+!! end
!!test
Templates: Wiki Tables: 3. td-content via multiple templates
!! html
a<div>bc</div>de
-!!end
+!! html+tidy
+<p>a</p>
+<div>bc</div>
+<p>de</p>
+!! end
!!test
Templates: Ugly templates: 1. Navbox template parses badly leading to table misnesting
<figure class="mw-default-size mw-halign-right" typeof="mw:Image mw:Placeholder"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"></a><figcaption>Caption text</figcaption></figure>
!! end
+# Parsoid's output here is broken (incorrect p-wrapping); see bug 64901.
!! test
Image with link tails
!! options
123<div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>456
123<div class="thumb tright"><div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div></div></div></div>456
+!! html/php+tidy
+<p>123<a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>456</p>
+<p>123</p>
+<div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>
+<p>456 123</p>
+<div class="thumb tright">
+<div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a>
+<div class="thumbcaption">
+<div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>
+</div>
+</div>
+</div>
+<p>456</p>
!! html/parsoid
<p>123<span class="mw-default-size" typeof="mw:Image"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"></a></span>456</p>
123<figure class="mw-default-size mw-halign-right" typeof="mw:Image"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"></a></figure>456
!! html
<p>I always thought é was a cute letter.
</p>
+!! html+tidy
+<p>I always thought é was a cute letter.</p>
!! end
!! test
!! end
# This was bug 41545 in the PHP parser.
+# Note that tidy doesn't handle this correctly.
!! test
Nesting of <kbd>
!! wikitext
# The following cases were bug 51081 in the PHP parser.
# Note that there are some other nestable tags (b, i, etc) which are
# not covered; see bug 51081 for discussion.
+
+# Note that tidy doesn't handle this correctly.
!! test
Nesting of <em>
!! wikitext
</p>
!! end
+# Note that tidy doesn't handle this correctly.
!! test
Nesting of <strong>
!! wikitext
Nesting of <q>
!! wikitext
<q>X<q>Y</q>Z</q>
-!! html
-<p><q>X<q>Y</q>Z</q>
-</p>
+!! html+tidy
+<p><q>X<q>Y</q>Z</q></p>
!! end
+# Note that tidy doesn't handle this correctly.
!! test
Nesting of <ruby>
!! wikitext
</p>
!! end
+# Note that tidy doesn't handle this correctly.
!! test
Nesting of <bdo>
!! wikitext
!! html
<a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Safe Link<div style="display:none">" onmouseover="alert(document.cookie)" onfoo="</div></a>
+!! html+tidy
+<p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Safe Link<div style="display:none">" onmouseover="alert(document.cookie)" onfoo="</div></a></p>
!! end
!! test
</div>
+!! html+tidy
+<h2><span class="mw-headline" id="onmouseover.3D">onmouseover=</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: onmouseover=">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
+<p>http://</p>
+<div id="toc" class="toc">
+<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>
+</div>
!! end
!! test
<tr><td></td></tr>
</table>
+!! html+tidy
+<h2><span class="mw-headline" id="a">a</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: a">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
+<table style="__TOC__">
+<tr>
+<td></td>
+</tr>
+</table>
!! end
# Known to produce bogus xml (extra </td>)
</tr>
</table>
+!! html+tidy
+<table>
+<tr>
+<th>https://</th>
+<th></th>
+<th></th>
+<th></th>
+</tr>
+</table>
!! end
!! test
!!test
Fuzz testing: URL adjacent extension (with space, clean)
-!! options
!! wikitext
http://example.com <nowiki>junk</nowiki>
!! html
!!test
Fuzz testing: URL adjacent extension (no space, dirty; nowiki)
-!! options
!! wikitext
http://example.com<nowiki>junk</nowiki>
!! html
!!test
Fuzz testing: URL adjacent extension (no space, dirty; pre)
-!! options
!! wikitext
http://example.com<pre>junk</pre>
!! html
<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a><pre>junk</pre>
+!! html+tidy
+<p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></p>
+<pre>
+junk
+</pre>
!!end
!!test
!! html/php
<p>JavaScript
</p>
+!! html/php+tidy
+<p>JavaScript</p>
!! html/parsoid
<p><span typeof="mw:Entity">J</span><span typeof="mw:Entity">a</span><span typeof="mw:Entity">v</span><span typeof="mw:Entity">a</span><span typeof="mw:Entity">S</span><span typeof="mw:Entity">c</span><span typeof="mw:Entity">r</span><span typeof="mw:Entity">i</span><span typeof="mw:Entity">p</span><span typeof="mw:Entity">t</span></p>
!! end
!! html/php
<p>îî
</p>
+!! html/php+tidy
+<p>îî</p>
!! html/parsoid
<p><span typeof="mw:Entity">î</span><span typeof="mw:Entity">î</span></p>
!! end
!! html
<p><a href="/wiki/Special:BookSources/9780123456" class="internal mw-magiclink-isbn">ISBN 978-0-1234-56</a> 789
</p>
+!! html+tidy
+<p><a href="/wiki/Special:BookSources/9780123456" class="internal mw-magiclink-isbn">ISBN 978-0-1234-56</a> 789</p>
!! end
!! test
!! html
<p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc983">RFC 983</a> 987
</p>
+!! html+tidy
+<p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc983">RFC 983</a> 987</p>
!! end
!! test
<blockquote>Line one
Line two</blockquote>
+!! html+tidy
+<blockquote>
+<p>Line one Line two</p>
+</blockquote>
!! end
!! test
</p>
Line two</blockquote>
+!! html+tidy
+<blockquote>
+<p>Line one</p>
+Line two</blockquote>
!! end
!! test
</p>
</blockquote>
+!! html+tidy
+<blockquote>
+<p>Line one</p>
+<p>Line two</p>
+</blockquote>
!! end
!! test
</p>
</blockquote>
+!! html+tidy
+<blockquote>
+<p>Line one</p>
+<p>Line two</p>
+</blockquote>
!! end
!! test
<h2><span class="mw-headline" id="Quote"><blockquote>Quote</blockquote></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Main_Page&action=edit&section=1" title="Edit section: Quote">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
+!! html+tidy
+<div id="toc" class="toc">
+<div id="toctitle">
+<h2>Contents</h2>
+</div>
+<ul>
+<li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
+</ul>
+</div>
+<h2><span class="mw-headline" id="Quote"></span></h2>
+<blockquote>
+<p><span class="mw-headline" id="Quote">Quote</span></p>
+</blockquote>
+<p><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Main_Page&action=edit&section=1" title="Edit section: Quote">edit</a><span class="mw-editsection-bracket">]</span></span></p>
!! end
!! test
<h2><span class="mw-headline" id="Foo_Bar"><i>Foo</i> <b>Bar</b></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
<h2><span class="mw-headline" id="Foo_Bar_2"><i>Foo</i> <blockquote>Bar</blockquote></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: Foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
+!! html+tidy
+<div id="toc" class="toc">
+<div id="toctitle">
+<h2>Contents</h2>
+</div>
+<ul>
+<li class="toclevel-1 tocsection-1"><a href="#Foo_Bar"><span class="tocnumber">1</span> <span class="toctext"><i>Foo</i> <b>Bar</b></span></a></li>
+<li class="toclevel-1 tocsection-2"><a href="#Foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext"><i>Foo</i> Bar</span></a></li>
+</ul>
+</div>
+<h2><span class="mw-headline" id="Foo_Bar"><i>Foo</i> <b>Bar</b></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
+<h2><span class="mw-headline" id="Foo_Bar_2"><i>Foo</i></span></h2>
+<blockquote>
+<p><span class="mw-headline" id="Foo_Bar_2">Bar</span></p>
+</blockquote>
+<p><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: Foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></p>
!! end
!! test
!! wikitext
==[[foo|x<nowiki>y</nowiki>z]]==
!! html
-<h2><span class="mw-headline" id="xyz"><a href="/index.php?title=Foo&action=edit&redlink=1" class="new" title="Foo (page does not exist)">xyz</a></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: xyz">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
+<h2><span class="mw-headline" id="xyz"><a href="/wiki/Foo" title="Foo">xyz</a></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: xyz">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
!! end
{|
|foo
|}
+!! html/php
+ <div>foo</div>
+<table>
+<tr>
+<td>foo
+</td></tr></table>
+
!! html/parsoid
<div data-parsoid='{"stx":"html"}'>foo</div>
<table><tbody>
<!--hi-->|-
| there
|}
+!! html/php
+<table>
+
+<tr>
+<td> there
+</td></tr></table>
+
!! html/parsoid
<table data-parsoid='{}'>
<!--hi--><tbody data-parsoid='{}'><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
private $sectionData = array();
private $lineNum;
private $eof;
+ # Create a fake parser tests which never run anything unless
+ # asked to do so. This will avoid running hooks for a disabled test
+ private $delayedParserTest;
+ private $nextSubTest = 0;
function __construct( $file, $parserTest ) {
$this->file = $file;
}
$this->parserTest = $parserTest;
+ $this->delayedParserTest = new DelayedParserTest();
$this->lineNum = $this->index = 0;
}
return $this->eof != true;
}
+ function setupCurrentTest() {
+ // "input" and "result" are old section names allowed
+ // for backwards-compatibility.
+ $input = $this->checkSection( array( 'wikitext', 'input' ), false );
+ $result = $this->checkSection( array( 'html/php', 'html/*', 'html', 'result' ), false );
+ // some tests have "with tidy" and "without tidy" variants
+ $tidy = $this->checkSection( array( 'html/php+tidy', 'html+tidy'), false );
+ if ( $tidy != false ) {
+ if ( $this->nextSubTest == 0 ) {
+ if ( $result != false ) {
+ $this->nextSubTest = 1; // rerun non-tidy variant later
+ }
+ $result = $tidy;
+ } else {
+ $this->nextSubTest = 0; // go on to next test after this
+ $tidy = false;
+ }
+ }
+
+ if ( !isset( $this->sectionData['options'] ) ) {
+ $this->sectionData['options'] = '';
+ }
+
+ if ( !isset( $this->sectionData['config'] ) ) {
+ $this->sectionData['config'] = '';
+ }
+
+ $isDisabled = preg_match( '/\\bdisabled\\b/i', $this->sectionData['options'] ) && !$this->parserTest->runDisabled;
+ $isParsoidOnly = preg_match( '/\\bparsoid\\b/i', $this->sectionData['options'] ) && $result == 'html' && !$this->parserTest->runParsoid;
+ $isFiltered = !preg_match( "/" . $this->parserTest->regex . "/i", $this->sectionData['test'] );
+ if ( $input == false || $result == false || $isDisabled || $isParsoidOnly || $isFiltered ) {
+ # disabled test
+ return false;
+ }
+
+ # We are really going to run the test, run pending hooks and hooks function
+ wfDebug( __METHOD__ . " unleashing delayed test for: {$this->sectionData['test']}" );
+ $hooksResult = $this->delayedParserTest->unleash( $this->parserTest );
+ if ( !$hooksResult ) {
+ # Some hook reported an issue. Abort.
+ throw new MWException( "Problem running hook" );
+ }
+
+ $this->test = array(
+ 'test' => ParserTest::chomp( $this->sectionData['test'] ),
+ 'input' => ParserTest::chomp( $this->sectionData[$input] ),
+ 'result' => ParserTest::chomp( $this->sectionData[$result] ),
+ 'options' => ParserTest::chomp( $this->sectionData['options'] ),
+ 'config' => ParserTest::chomp( $this->sectionData['config'] ),
+ );
+ if ( $tidy != false ) {
+ $this->test['options'] .= " tidy";
+ }
+ return true;
+ }
+
function readNextTest() {
- $this->clearSection();
+ # Run additional subtests of previous test
+ while ( $this->nextSubTest > 0 )
+ if ( $this->setupCurrentTest() )
+ return true;
- # Create a fake parser tests which never run anything unless
- # asked to do so. This will avoid running hooks for a disabled test
- $delayedParserTest = new DelayedParserTest();
+ $this->clearSection();
+ # Reset hooks for the delayed test object
+ $this->delayedParserTest->reset();
while ( false !== ( $line = fgets( $this->fh ) ) ) {
$this->lineNum++;
$line = trim( $line );
if ( $line ) {
- $delayedParserTest->requireHook( $line );
+ $this->delayedParserTest->requireHook( $line );
}
}
$line = trim( $line );
if ( $line ) {
- $delayedParserTest->requireFunctionHook( $line );
+ $this->delayedParserTest->requireFunctionHook( $line );
}
}
if ( $this->section == 'end' ) {
$this->checkSection( 'test' );
- // "input" and "result" are old section names allowed
- // for backwards-compatibility.
- $input = $this->checkSection( array( 'wikitext', 'input' ), false );
- $result = $this->checkSection( array( 'html/php', 'html/*', 'html', 'result' ), false );
-
- if ( !isset( $this->sectionData['options'] ) ) {
- $this->sectionData['options'] = '';
- }
-
- if ( !isset( $this->sectionData['config'] ) ) {
- $this->sectionData['config'] = '';
- }
-
- if ( $input == false || $result == false ||
- ( ( preg_match( '/\\bdisabled\\b/i', $this->sectionData['options'] )
- && !$this->parserTest->runDisabled )
- || ( preg_match( '/\\bparsoid\\b/i', $this->sectionData['options'] )
- && $result != 'html/php' && !$this->parserTest->runParsoid )
- || !preg_match( "/" . $this->parserTest->regex . "/i", $this->sectionData['test'] ) )
- ) {
- # disabled test
- $this->clearSection();
-
- # Forget any pending hooks call since test is disabled
- $delayedParserTest->reset();
-
- continue;
- }
-
- # We are really going to run the test, run pending hooks and hooks function
- wfDebug( __METHOD__ . " unleashing delayed test for: {$this->sectionData['test']}" );
- $hooksResult = $delayedParserTest->unleash( $this->parserTest );
- if ( !$hooksResult ) {
- # Some hook reported an issue. Abort.
- return false;
- }
-
- $this->test = array(
- 'test' => ParserTest::chomp( $this->sectionData['test'] ),
- 'input' => ParserTest::chomp( $this->sectionData[$input] ),
- 'result' => ParserTest::chomp( $this->sectionData[$result] ),
- 'options' => ParserTest::chomp( $this->sectionData['options'] ),
- 'config' => ParserTest::chomp( $this->sectionData['config'] ),
- );
-
- return true;
+ do {
+ if ( $this->setupCurrentTest() )
+ return true;
+ } while ( $this->nextSubTest > 0 );
+ # go on to next test (since this was disabled)
+ $this->clearSection();
+ $this->delayedParserTest->reset();
+ continue;
}
if ( isset( $this->sectionData[$this->section] ) ) {
}
/**
- * Returns if the DjVu tools are usable
+ * Returns true if the DjVu tools are usable
*
* @return bool
*/
&& is_executable( $wgDjvuTxt );
}
}
+
+/**
+ * Initialize and detect the tidy support
+ */
+class TidySupport {
+ private $internalTidy;
+ private $externalTidy;
+
+ /**
+ * Determine if there is a usable tidy.
+ */
+ public function __construct() {
+ global $wgTidyBin;
+
+ $this->internalTidy = extension_loaded( 'tidy' ) &&
+ class_exists( 'tidy' );
+
+ $this->externalTidy = is_executable( $wgTidyBin ) ||
+ Installer::locateExecutableInDefaultPaths( array( $wgTidyBin ) )
+ !== false;
+ }
+
+ /**
+ * Returns true if we should use internal tidy.
+ *
+ * @return bool
+ */
+ public function isInternal() {
+ return $this->internalTidy;
+ }
+
+ /**
+ * Returns true if tidy is usable
+ *
+ * @return bool
+ */
+ public function isEnabled() {
+ return $this->internalTidy || $this->externalTidy;
+ }
+}