Merge "ParserTestRunner: handle metadata output as separate section"

This commit is contained in:
jenkins-bot 2023-03-01 19:11:39 +00:00 committed by Gerrit Code Review
commit fca2f11ff5
6 changed files with 244 additions and 123 deletions

View file

@ -987,13 +987,17 @@ class ParserTestRunner {
return "Test doesn't match filter";
}
// Skip parsoid-only tests if running in a legacy test mode
if ( $test->legacyHtml === null ) {
if (
$test->legacyHtml === null &&
self::getLegacyMetadataSection( $test ) === null
) {
// A Parsoid-only test should have one of the following sections
if (
isset( $test->sections['html/parsoid'] ) ||
isset( $test->sections['html/parsoid+integrated'] ) ||
isset( $test->sections['html/parsoid+standalone'] ) ||
isset( $test->sections['wikitext/edited'] )
isset( $test->sections['wikitext/edited'] ) ||
self::getParsoidMetadataSection( $test ) !== null
) {
if ( $mode->isLegacy() ) {
// Not an error, just skip this test if we're in
@ -1001,14 +1005,39 @@ class ParserTestRunner {
return "Parsoid-only test";
}
} else {
// This test lacks both a legacy html section and also
// any parsoid-specific html or wikitext/edited section.
$test->error( "Test lacks html section", $test->testName );
// This test lacks both a legacy html or metadata
// section and also any parsoid-specific html or
// metadata section or wikitext/edited section.
$test->error( "Test lacks html or metadata section", $test->testName );
}
}
return null;
}
public static function getLegacyMetadataSection( ParserTest $test ) {
return // specific results for legacy parser
$test->sections['metadata/php'] ??
// specific results for legacy parser and parsoid integrated mode
$test->sections['metadata/integrated'] ??
// generic for all parsers (even standalone)
$test->sections['metadata'] ??
// missing (== use legacy combined output format)
null;
}
public static function getParsoidMetadataSection( ParserTest $test ) {
return // specific results for parsoid integrated mode
$test->sections['metadata/parsoid+integrated'] ??
// specific results for parsoid
$test->sections['metadata/parsoid'] ??
// specific results for legacy parser and parsoid integrated mode
$test->sections['metadata/integrated'] ??
// generic for all parsers (even standalone)
$test->sections['metadata'] ??
// missing (== use legacy combined output format)
null;
}
/**
* Compute valid test modes based on requested modes and file-enabled modes
* @param array $testModes
@ -1360,14 +1389,19 @@ class ParserTestRunner {
$out = preg_replace( '/\s+$/', '', $out );
}
}
$metadataExpected = self::getLegacyMetadataSection( $test );
$metadataActual = null;
if ( $output ) {
$this->addParserOutputInfo( $out, $output, $opts, $title );
$this->addParserOutputInfo(
$out, $output, $opts, $title,
$metadataExpected, $metadataActual
);
}
ScopedCallback::consume( $teardownGuard );
$expected = $test->legacyHtml;
'@phan-var string $expected'; // assert that this is not null
$expected = $test->legacyHtml ?? '';
if ( count( $this->normalizationFunctions ) ) {
$expected = ParserTestResultNormalizer::normalize(
$expected, $this->normalizationFunctions );
@ -1375,56 +1409,59 @@ class ParserTestRunner {
}
$testResult = new ParserTestResult( $test, $mode, $expected, $out );
if ( $testResult->isSuccess() && $metadataExpected !== null ) {
$testResult = new ParserTestResult( $test, $mode, $metadataExpected, $metadataActual ?? '' );
}
return $testResult;
}
/**
* Add information from the parser output to the result string
*
* @param string &$out
* @param ParserOutput $output
* @param array $opts
* @param string &$out The "actual" parser output
* @param ParserOutput $output The "actual" parser metadata
* @param array $opts Test options
* @param Title $title
* @param ?string $metadataExpected The contents of the !!metadata section,
* or null if it is missing
* @param ?string &$metadataActual The "actual" metadata output
*/
private function addParserOutputInfo( &$out, ParserOutput $output, array $opts, Title $title ) {
private function addParserOutputInfo(
&$out, ParserOutput $output, array $opts, Title $title,
?string $metadataExpected, ?string &$metadataActual
) {
$before = [];
$after = [];
// The "before" entries may contain HTML.
if ( isset( $opts['showtitle'] ) ) {
if ( $output->getTitleText() ) {
$titleText = $output->getTitleText();
} else {
$titleText = $title->getPrefixedText();
}
$out = "$titleText\n$out";
$before[] = $titleText;
}
if ( isset( $opts['showindicators'] ) ) {
$indicators = '';
foreach ( $output->getIndicators() as $id => $content ) {
$indicators .= "$id=$content\n";
$before[] = "$id=$content";
}
$out = $indicators . $out;
}
if ( isset( $opts['ill'] ) ) {
if ( $out !== '' ) {
$out .= "\n";
}
$out .= implode( ' ', $output->getLanguageLinks() );
} elseif ( isset( $opts['cat'] ) ) {
$after[] = implode( ' ', $output->getLanguageLinks() );
}
if ( isset( $opts['cat'] ) ) {
foreach ( $output->getCategories() as $name => $sortkey ) {
if ( $out !== '' ) {
$out .= "\n";
}
$out .= "cat=$name sort=$sortkey";
$after[] = "cat=$name sort=$sortkey";
}
}
if ( isset( $opts['extension'] ) ) {
foreach ( explode( ',', $opts['extension'] ) as $ext ) {
if ( $out !== '' ) {
$out .= "\n";
}
$out .= "extension[$ext]=" .
$after[] = "extension[$ext]=" .
// XXX should use JsonCodec
json_encode(
$output->getExtensionData( $ext ),
JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT
@ -1434,10 +1471,7 @@ class ParserTestRunner {
if ( isset( $opts['property'] ) ) {
foreach ( explode( ',', $opts['property'] ) as $prop ) {
if ( $out !== '' ) {
$out .= "\n";
}
$out .= "property[$prop]=" .
$after[] = "property[$prop]=" .
( $output->getPageProperty( $prop ) ?? '' );
}
}
@ -1457,10 +1491,7 @@ class ParserTestRunner {
}
}
sort( $actualFlags );
if ( $out !== '' ) {
$out .= "\n";
}
$out .= "flags=" . implode( ', ', $actualFlags );
$after[] = "flags=" . implode( ', ', $actualFlags );
# In 1.21 we deprecated the use of arbitrary keys for
# ParserOutput::setFlag() by extensions; if we find anyone
# still doing that complain about it.
@ -1476,14 +1507,24 @@ class ParserTestRunner {
// FIXME: We probably want to update this to a different format
$sections = $output->getTOCData() !== null ?
$output->getTOCData()->getSections() : [];
$toc = [];
foreach ( $sections as $s ) {
$toc[] = json_encode( $s->toLegacy() );
$after[] = json_encode( $s->toLegacy() );
}
if ( $out !== '' ) {
$out .= "\n";
}
if ( $metadataExpected === null ) {
// legacy format, add $before and $after to $out
if ( $before ) {
$before = implode( "\n", $before );
$out = "$before\n$out";
}
$out .= implode( "\n", $toc );
if ( $after ) {
if ( $out && !str_ends_with( $out, "\n" ) ) {
$out .= "\n";
}
$out .= implode( "\n", $after );
}
} else {
$metadataActual = implode( "\n", array_merge( $before, $after ) );
}
}

View file

@ -235,11 +235,12 @@ ill
[[es:]]
[[ko:]]
!! metadata
es:
!! html/php
<p><br />
<a href="/wiki/Ko:" title="Ko:">ko:</a>
</p>
es:
!! html/parsoid
<link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/"/>

View file

@ -625,10 +625,11 @@ parsoid={ "modes": ["wt2html","wt2wt"] }
showflags
!! wikitext
{{REVISIONID}}
!! metadata/integrated
flags=vary-revision-id
!! html/php
<p>1337
</p>
flags=vary-revision-id
!! html/parsoid+integrated
<p><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"REVISIONID","function":"revisionid"},"params":{},"i":0}}]}'>1337</span></p>
!! end
@ -640,10 +641,11 @@ parsoid={ "modes": ["wt2html","wt2wt"] }
showflags
!! wikitext
{{REVISIONID}}
!! metadata/integrated
flags=vary-revision-id
!! html/php
<p>1337
</p>
flags=vary-revision-id
!! html/parsoid+integrated
<p><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"REVISIONID","function":"revisionid"},"params":{},"i":0}}]}'>1337</span></p>
!! end
@ -656,10 +658,11 @@ parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
showflags
!! wikitext
{{REVISIONTIMESTAMP}}
!! metadata/integrated
flags=
!! html/php
<p>19700101000203
</p>
flags=
!! html/parsoid+integrated
<p><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"REVISIONTIMESTAMP","function":"revisiontimestamp"},"params":{},"i":0}}]}'>19700101000203</span></p>
!! end
@ -672,10 +675,11 @@ parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
showflags
!! wikitext
{{REVISIONTIMESTAMP:{{PAGENAME}}}}
!! metadata/integrated
flags=
!! html/php
<p>19700101000203
</p>
flags=
!! html/parsoid+integrated
<p><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"REVISIONTIMESTAMP:{{PAGENAME}}","function":"revisiontimestamp"},"params":{},"i":0}}]}'>19700101000203</span></p>
!! end
@ -688,10 +692,11 @@ parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
showflags
!! wikitext
{{REVISIONTIMESTAMP}}
!! metadata/integrated
flags=vary-revision-timestamp
!! html/php
<p>19700101000203
</p>
flags=vary-revision-timestamp
!! html/parsoid+integrated
<p><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"REVISIONTIMESTAMP","function":"revisiontimestamp"},"params":{},"i":0}}]}'>19700101000203</span></p>
!! end
@ -704,10 +709,11 @@ parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
showflags
!! wikitext
{{REVISIONTIMESTAMP:{{PAGENAME}}}}
!! metadata/integrated
flags=vary-revision-timestamp
!! html/php
<p>19700101000203
</p>
flags=vary-revision-timestamp
!! html/parsoid+integrated
<p><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"REVISIONTIMESTAMP:{{PAGENAME}}","function":"revisiontimestamp"},"params":{},"i":0}}]}'>19700101000203</span></p>
!! end
@ -719,8 +725,9 @@ parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
showflags
!! wikitext
{{REVISIONTIMESTAMP:This page does not exist}}
!! html/php
!! metadata/integrated
flags=
!! html/php
!! html/parsoid+integrated
<span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"REVISIONTIMESTAMP:This page does not exist","function":"revisiontimestamp"},"params":{},"i":0}}]}'></span>
!! end
@ -733,10 +740,11 @@ parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
showflags
!! wikitext
{{REVISIONUSER}}
!! metadata/integrated
flags=vary-user
!! html/php
<p>127.0.0.1
</p>
flags=vary-user
!! html/parsoid+integrated
<p><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"REVISIONUSER","function":"revisionuser"},"params":{},"i":0}}]}'>127.0.0.1</span></p>
!! end
@ -749,8 +757,9 @@ parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
showflags
!! wikitext
{{REVISIONUSER}}
!! html/php
!! metadata/integrated
flags=vary-user
!! html/php
!! html/parsoid+integrated
<span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"REVISIONUSER","function":"revisionuser"},"params":{},"i":0}}]}'></span>
!! end
@ -763,8 +772,9 @@ parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
showflags
!! wikitext
{{REVISIONUSER:{{PAGENAME}}}}
!! html/php
!! metadata/integrated
flags=vary-user
!! html/php
!! html/parsoid+integrated
<span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"REVISIONUSER:{{PAGENAME}}","function":"revisionuser"},"params":{},"i":0}}]}'></span>
!! end
@ -776,8 +786,9 @@ parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
showflags
!! wikitext
{{REVISIONUSER:This page does not exist}}
!! html/php
!! metadata/integrated
flags=
!! html/php
!! html/parsoid+integrated
<span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"REVISIONUSER:This page does not exist","function":"revisionuser"},"params":{},"i":0}}]}'></span>
!! end
@ -789,8 +800,9 @@ parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
showflags
!! wikitext
{{REVISIONUSER}}
!! html/php
!! metadata/integrated
flags=vary-user
!! html/php
!! html/parsoid+integrated
<span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"REVISIONUSER","function":"revisionuser"},"params":{},"i":0}}]}'></span>
!! end
@ -803,10 +815,11 @@ parsoid={ "modes": ["wt2html","wt2wt"] }
showflags
!! wikitext
{{REVISIONID:{{PAGENAME}}}}
!! metadata/integrated
flags=vary-revision-id
!! html/php
<p>1337
</p>
flags=vary-revision-id
!! html/parsoid+integrated
<p><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"REVISIONID:{{PAGENAME}}","function":"revisionid"},"params":{},"i":0}}]}'>1337</span></p>
!! end
@ -818,8 +831,9 @@ parsoid={ "modes": ["wt2html","wt2wt"] }
showflags
!! wikitext
{{REVISIONID:{{PAGENAME}}}}
!! html/php
!! metadata/integrated
flags=vary-revision-id
!! html/php
!! html/parsoid+integrated
<span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"REVISIONID:{{PAGENAME}}","function":"revisionid"},"params":{},"i":0}}]}'></span>
!! end
@ -832,10 +846,11 @@ parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
showflags
!! wikitext
{{REVISIONDAY}}
!! metadata/integrated
flags=
!! html/php
<p>1
</p>
flags=
!! html/parsoid+integrated
<p><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"REVISIONDAY","function":"revisionday"},"params":{},"i":0}}]}'>1</span></p>
!! end
@ -848,10 +863,11 @@ parsoid={ "modes": ["wt2html","wt2wt"] }
showflags
!! wikitext
{{REVISIONDAY:{{PAGENAME}}}}
!! metadata/integrated
flags=
!! html/php
<p>1
</p>
flags=
!! html/parsoid+integrated
<p><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"REVISIONDAY:{{PAGENAME}}","function":"revisionday"},"params":{},"i":0}}]}'>1</span></p>
!! end
@ -864,10 +880,11 @@ parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
showflags
!! wikitext
{{REVISIONMONTH}}
!! metadata/integrated
flags=
!! html/php
<p>01
</p>
flags=
!! html/parsoid+integrated
<p><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"REVISIONMONTH","function":"revisionmonth"},"params":{},"i":0}}]}'>01</span></p>
!! end
@ -880,10 +897,11 @@ parsoid={ "modes": ["wt2html","wt2wt"] }
showflags
!! wikitext
{{REVISIONMONTH:{{PAGENAME}}}}
!! metadata/integrated
flags=
!! html/php
<p>01
</p>
flags=
!! html/parsoid+integrated
<p><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"REVISIONMONTH:{{PAGENAME}}","function":"revisionmonth"},"params":{},"i":0}}]}'>01</span></p>
!! end
@ -896,10 +914,11 @@ parsoid={ "modes": ["wt2html","wt2wt"] }
showflags
!! wikitext
{{REVISIONYEAR:{{PAGENAME}}}}
!! metadata/integrated
flags=
!! html/php
<p>1970
</p>
flags=
!! html/parsoid+integrated
<p><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"REVISIONYEAR:{{PAGENAME}}","function":"revisionyear"},"params":{},"i":0}}]}'>1970</span></p>
!! end
@ -912,10 +931,11 @@ parsoid={ "modes": ["wt2html","wt2wt"] }
showflags
!! wikitext
{{PAGESIZE:{{PAGENAME}}}}
!! metadata/integrated
flags=vary-revision-sha1
!! html/php
<p>25
</p>
flags=vary-revision-sha1
!! html/parsoid+integrated
<p><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"PAGESIZE:{{PAGENAME}}","function":"pagesize"},"params":{},"i":0}}]}'>25</span></p>
!! end

View file

@ -4055,9 +4055,9 @@ wgAllowDisplayTitle=true
wgRestrictDisplayTitle=false
!! wikitext
{{DISPLAYTITLE:''{{PAGENAME}}''}}
!! html/php
!! metadata
<i>Parser test</i>
!! html/php
!! html/parsoid
<meta property="mw:PageProp/displaytitle" content="Parser test" about="#mwt3" typeof="mw:ExpandedAttrs" data-parsoid='{"src":"{{DISPLAYTITLE:&#39;&#39;{{PAGENAME}}&#39;&#39;}}"}' data-mw='{"attribs":[[{"txt":"content"},{"html":"DISPLAYTITLE:&lt;i data-parsoid=&#39;{\"dsr\":[15,31,2,2]}&#39;>&lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[]],\"dsr\":[17,29,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"PAGENAME\",\"function\":\"pagename\"},\"params\":{},\"i\":0}}]}&#39;>Parser test&lt;/span>&lt;/i>"}]]}'/>
!! end
@ -4074,9 +4074,9 @@ showtitle
!! config
wgAllowDisplayTitle=true
wgRestrictDisplayTitle=false
!! html/php
!! metadata
Foo
!! html/php
!! html/parsoid
<meta property="mw:PageProp/displaytitle" content="Foo" about="#mwt1" typeof="mw:ExpandedAttrs" data-mw='{"attribs":[[{"txt":"content"},{"html":"&lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[{\"k\":\"1\"}]],\"dsr\":[2,23,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"1x\",\"href\":\"./Template:1x\"},\"params\":{\"1\":{\"wt\":\"DISPLAYTITLE\"}},\"i\":0}}]}&#39;>DISPLAYTITLE&lt;/span>:Foo"}]]}'/>
!! end
@ -7876,12 +7876,13 @@ __NOTOC__
==Section 0==
{{sections}}
==Section 4==
!! metadata
flags=
!! html/php
<h2><span class="mw-headline" id="Section_0">Section 0</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: Section 0">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
<h3><span class="mw-headline" id="Section_1">Section 1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Template:Sections&amp;action=edit&amp;section=T-1" title="Edit section: Section 1">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
<h2><span class="mw-headline" id="Section_2">Section 2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Template:Sections&amp;action=edit&amp;section=T-2" title="Edit section: Section 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
<h2><span class="mw-headline" id="Section_4">Section 4</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: Section 4">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
flags=
!! end
!! test
@ -7889,8 +7890,9 @@ T307691: show-toc flag: no sections
!! options
showflags
!! wikitext
!! html/php
!! metadata
flags=
!! html
!! end
# You can't force a TOC if there aren't any sections
@ -7900,8 +7902,11 @@ T307691: show-toc flag: no sections, but __FORCETOC__
showflags
!! wikitext
__FORCETOC__
!! html/php
!! metadata
flags=
!! html/php
!! html/parsoid
<meta property="mw:PageProp/forcetoc"/>
!! end
# Placing a manual __TOC__ doesn't do anything if there aren't any sections
@ -7911,8 +7916,11 @@ T307691: show-toc flag: no sections, but __TOC__
showflags
!! wikitext
__TOC__
!! html/php
!! metadata
flags=
!! html/php
!! html/parsoid
<meta property="mw:PageProp/toc"/>
!! end
!! test
@ -7921,8 +7929,11 @@ T307691: show-toc flag: no sections, and __NOTOC__
showflags
!! wikitext
__NOTOC__
!! html/php
!! metadata
flags=
!! html/php
!! html/parsoid
<meta property="mw:PageProp/notoc"/>
!! end
!! test
@ -7931,9 +7942,12 @@ T307691: show-toc flag: not "enough" sections
showflags
!! wikitext
== One ==
!! metadata
flags=
!! html/php
<h2><span class="mw-headline" id="One">One</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: One">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
flags=
!! html/parsoid
<h2 id="One">One</h2>
!! end
!! test
@ -7943,6 +7957,8 @@ showflags
!! wikitext
__FORCETOC__
== One ==
!! metadata
flags=show-toc
!! html/php
<div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
<ul>
@ -7951,7 +7967,9 @@ __FORCETOC__
</div>
<h2><span class="mw-headline" id="One">One</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: One">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
flags=show-toc
!! html/parsoid
<meta property="mw:PageProp/forcetoc"/>
<h2 id="One">One</h2>
!! end
!! test
@ -7961,6 +7979,8 @@ showflags
!! wikitext
== One ==
__TOC__
!! metadata
flags=show-toc
!! html/php
<h2><span class="mw-headline" id="One">One</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: One">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
<div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
@ -7968,7 +7988,9 @@ __TOC__
<li class="toclevel-1 tocsection-1"><a href="#One"><span class="tocnumber">1</span> <span class="toctext">One</span></a></li>
</ul>
</div>
flags=show-toc
!! html/parsoid
<h2 id="One">One</h2>
<meta property="mw:PageProp/toc"/>
!! end
!! test
@ -7978,9 +8000,13 @@ showflags
!! wikitext
__NOTOC__
== One ==
!! metadata
flags=
!! html/php
<h2><span class="mw-headline" id="One">One</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: One">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
flags=
!! html/parsoid
<meta property="mw:PageProp/notoc"/>
<h2 id="One">One</h2>
!! end
!! test
@ -7992,6 +8018,8 @@ showflags
=== Two ===
== Three ==
=== Four ===
!! metadata
flags=show-toc
!! html/php
<div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
<ul>
@ -8012,7 +8040,11 @@ showflags
<h3><span class="mw-headline" id="Two">Two</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: Two">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
<h2><span class="mw-headline" id="Three">Three</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: Three">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
<h3><span class="mw-headline" id="Four">Four</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: Four">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
flags=show-toc
!! html/parsoid
<h2 id="One">One</h2>
<h3 id="Two">Two</h3>
<h2 id="Three">Three</h2>
<h3 id="Four">Four</h3>
!! end
!! test
@ -8025,6 +8057,8 @@ __FORCETOC__
=== Two ===
== Three ==
=== Four ===
!! metadata
flags=show-toc
!! html/php
<div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
<ul>
@ -8045,7 +8079,12 @@ __FORCETOC__
<h3><span class="mw-headline" id="Two">Two</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: Two">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
<h2><span class="mw-headline" id="Three">Three</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: Three">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
<h3><span class="mw-headline" id="Four">Four</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: Four">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
flags=show-toc
!! html/parsoid
<meta property="mw:PageProp/forcetoc"/>
<h2 id="One">One</h2>
<h3 id="Two">Two</h3>
<h2 id="Three">Three</h2>
<h3 id="Four">Four</h3>
!! end
!! test
@ -8058,12 +8097,19 @@ __NOTOC__
=== Two ===
== Three ==
=== Four ===
!! metadata
flags=
!! html/php
<h2><span class="mw-headline" id="One">One</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: One">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
<h3><span class="mw-headline" id="Two">Two</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: Two">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
<h2><span class="mw-headline" id="Three">Three</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: Three">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
<h3><span class="mw-headline" id="Four">Four</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: Four">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
flags=
!! html/parsoid
<meta property="mw:PageProp/notoc"/>
<h2 id="One">One</h2>
<h3 id="Two">Two</h3>
<h2 id="Three">Three</h2>
<h3 id="Four">Four</h3>
!! end
!! test
@ -11789,10 +11835,14 @@ showflags
!! wikitext
__NEWSECTIONLINK__
__FORCETOC__
!! metadata
flags=mw-NewSection
!! html/php
<p><br />
</p>
flags=mw-NewSection
!! html/parsoid
<meta property="mw:PageProp/newsectionlink"/>
<meta property="mw:PageProp/forcetoc"/>
!! end
!! test
@ -13146,8 +13196,9 @@ wgAllowDisplayTitle=true
wgRestrictDisplayTitle=false
!! wikitext
this is not the title
!! html/php
!! metadata
<span class="mw-page-title-main">Parser test</span>
!! html
<p>this is not the title
</p>
!! end
@ -13163,8 +13214,9 @@ wgRestrictDisplayTitle=false
!! wikitext
this is not the title
{{DISPLAYTITLE:whatever}}
!! html/php
!! metadata
whatever
!! html
<p>this is not the title
</p>
!! end
@ -13180,8 +13232,9 @@ wgRestrictDisplayTitle=true
!! wikitext
this is not the title
{{DISPLAYTITLE:whatever}}
!! html/php
!! metadata
<span class="mw-page-title-main">Screen</span>
!! html
<p>this is not the title
</p>
!! end
@ -13197,8 +13250,9 @@ wgRestrictDisplayTitle=true
!! wikitext
this is not the title
{{DISPLAYTITLE:screen}}
!! html/php
!! metadata
screen
!! html
<p>this is not the title
</p>
!! end
@ -13213,8 +13267,9 @@ wgAllowDisplayTitle=false
!! wikitext
this is not the title
{{DISPLAYTITLE:screen}}
!! html/php
!! metadata
<span class="mw-page-title-main">Screen</span>
!! html/php
<p>this is not the title
<a href="/index.php?title=Template:DISPLAYTITLE:screen&amp;action=edit&amp;redlink=1" class="new" title="Template:DISPLAYTITLE:screen (page does not exist)">Template:DISPLAYTITLE:screen</a>
</p>
@ -13229,8 +13284,9 @@ title=[[Screen]]
wgAllowDisplayTitle=false
!! wikitext
this is not the title
!! html/php
!! metadata
<span class="mw-page-title-main">Screen</span>
!! html
<p>this is not the title
</p>
!! end
@ -13246,8 +13302,9 @@ wgRestrictDisplayTitle=true
!! wikitext
this is not the title
{{DISPLAYTITLE:<span style="display: none;">s</span>creen}}
!! html/php
!! metadata
<span style="/* attempt to bypass $wgRestrictDisplayTitle */">s</span>creen
!! html/php
<p>this is not the title
</p>
!! end
@ -13263,8 +13320,9 @@ wgRestrictDisplayTitle=true
!! wikitext
this is not the title
{{DISPLAYTITLE:<span style="color: red;">s</span>creen}}
!! html/php
!! metadata
<span style="color: red;">s</span>creen
!! html/php
<p>this is not the title
</p>
!! end
@ -13280,8 +13338,9 @@ wgRestrictDisplayTitle=true
!! wikitext
this is not the title
{{DISPLAYTITLE:art&copy}}
!! html/php
!! metadata
art&amp;copy
!! html
<p>this is not the title
</p>
!! end
@ -13297,8 +13356,9 @@ wgRestrictDisplayTitle=true
!! wikitext
this is not the title
{{DISPLAYTITLE:art&amp;copy}}
!! html/php
!! metadata
art&amp;copy
!! html/php
<p>this is not the title
</p>
!! end
@ -13313,8 +13373,9 @@ wgAllowDisplayTitle=true
wgRestrictDisplayTitle=true
!! wikitext
this is not the title
!! html/php
!! metadata
<span class="mw-page-title-main">Art&amp;copy</span>
!! html
<p>this is not the title
</p>
!! end
@ -13339,9 +13400,10 @@ showindicators
!! wikitext
<indicator name="empty" />
<indicator name="name"></indicator>
!! html/php
!! metadata
empty=
name=
!! html
<p><br />
</p>
!! end
@ -13349,6 +13411,7 @@ name=
!! test
Page status indicators: Torture test
!! options
nohtml
showindicators
!! config
wgParserEnableLegacyMediaDOM=false
@ -13368,7 +13431,7 @@ wgParserEnableLegacyMediaDOM=false
<indicator name="10">Two
paragraphs</indicator>
!! html/php
!! metadata
01=hello world
02=<a href="/wiki/Main_Page" title="Main Page">Main Page</a>
03=<span typeof="mw:File"><span><img src="http://example.com/images/thumb/3/3a/Foobar.jpg/25px-Foobar.jpg" decoding="async" width="25" height="3" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/38px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg 2x" /></span></span>
@ -13386,12 +13449,7 @@ paragraphs</indicator>
10=<p>Two
</p><p>paragraphs
</p>
<p><br />
</p><p><br />
</p><p><br />
</p><p><br />
</p><p><br />
</p>
!! html
!! end
!! test
@ -17902,9 +17960,9 @@ parsoid=wt2html,html2html
showindicators
!! wikitext
<indicator name="1&2&amp;3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
!! html/php
!! metadata
1&2&3&amp;4&amp;amp;5=Indicator
!! html/php
!! html/parsoid
<p><link typeof="mw:Extension/indicator" about="#mwt3" data-mw='{"name":"indicator","attrs":{"name":"1&amp;2&amp;3&amp;amp;4&amp;amp;amp;5"},"body":{"extsrc":"Indicator"}}' /></p>
!! end
@ -17916,9 +17974,9 @@ Decoding of HTML entities in indicator names for IDs (unambiguous) (T104196)
showindicators
!! wikitext
<indicator name="1&2&3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
!! html/php
!! metadata
1&2&3&amp;4&amp;amp;5=Indicator
!! html/php
!! html/parsoid
<p><link typeof="mw:Extension/indicator" about="#mwt3" data-mw='{"name":"indicator","attrs":{"name":"1&amp;2&amp;3&amp;amp;4&amp;amp;amp;5"},"body":{"extsrc":"Indicator"}}' /></p>
!! end

View file

@ -564,9 +564,10 @@ pst
showflags
!! wikitext
~~~~
!! metadata
flags=!no-toc-conversion, user-signature
!! html/php
[[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
flags=!no-toc-conversion, user-signature
!! end
!! test

View file

@ -36,7 +36,7 @@ parsoid={
====h2.2.1====
====h2.2.2====
==h3==
!! html
!! metadata
{"toclevel":1,"level":"2","line":"h1","number":"1","index":"1","fromtitle":"Parser_test","byteoffset":0,"anchor":"h1","linkAnchor":"h1"}
{"toclevel":2,"level":"3","line":"h1.1","number":"1.1","index":"2","fromtitle":"Parser_test","byteoffset":7,"anchor":"h1.1","linkAnchor":"h1.1"}
{"toclevel":1,"level":"2","line":"h2","number":"2","index":"3","fromtitle":"Parser_test","byteoffset":18,"anchor":"h2","linkAnchor":"h2"}
@ -63,7 +63,7 @@ parsoid={
<h3>c</h3>
===d===
<h2>e</h2>
!! html
!! metadata
{"toclevel":1,"level":"2","line":"a","number":"1","index":"1","fromtitle":"Parser_test","byteoffset":0,"anchor":"a","linkAnchor":"a"}
{"toclevel":1,"level":"2","line":"b","number":"2","index":"","fromtitle":false,"byteoffset":null,"anchor":"b","linkAnchor":"b"}
{"toclevel":2,"level":"3","line":"c","number":"2.1","index":"","fromtitle":false,"byteoffset":null,"anchor":"c","linkAnchor":"c"}
@ -84,7 +84,7 @@ parsoid={
==a==
==a==
==b==
!! html
!! metadata
{"toclevel":1,"level":"2","line":"a","number":"1","index":"1","fromtitle":"Parser_test","byteoffset":0,"anchor":"a","linkAnchor":"a"}
{"toclevel":1,"level":"2","line":"a","number":"2","index":"2","fromtitle":"Parser_test","byteoffset":6,"anchor":"a_2","linkAnchor":"a_2"}
{"toclevel":1,"level":"2","line":"b","number":"3","index":"3","fromtitle":"Parser_test","byteoffset":12,"anchor":"b","linkAnchor":"b"}
@ -102,7 +102,7 @@ parsoid={
!! wikitext
==a==
{{Test}}
!! html
!! metadata
{"toclevel":1,"level":"2","line":"a","number":"1","index":"1","fromtitle":"Parser_test","byteoffset":0,"anchor":"a","linkAnchor":"a"}
{"toclevel":1,"level":"2","line":"th2","number":"2","index":"T-1","fromtitle":"Template:Test","byteoffset":null,"anchor":"th2","linkAnchor":"th2"}
{"toclevel":2,"level":"3","line":"th2.1","number":"2.1","index":"T-2","fromtitle":"Template:Test","byteoffset":null,"anchor":"th2.1","linkAnchor":"th2.1"}
@ -120,7 +120,7 @@ parsoid={
!! wikitext
==<span>x</span>==
==<strike>y</strike>==
!! html
!! metadata
{"toclevel":1,"level":"2","line":"<span>x<\/span>","number":"1","index":"1","fromtitle":"Parser_test","byteoffset":0,"anchor":"x","linkAnchor":"x"}
{"toclevel":1,"level":"2","line":"<strike>y<\/strike>","number":"2","index":"2","fromtitle":"Parser_test","byteoffset":19,"anchor":"y","linkAnchor":"y"}
!! end
@ -137,7 +137,7 @@ parsoid={
!! wikitext
==<div>b</div>==
==<font>c</font>==
!! html
!! metadata
{"toclevel":1,"level":"2","line":"b","number":"1","index":"1","fromtitle":"Parser_test","byteoffset":0,"anchor":"b","linkAnchor":"b"}
{"toclevel":1,"level":"2","line":"c","number":"2","index":"2","fromtitle":"Parser_test","byteoffset":17,"anchor":"c","linkAnchor":"c"}
!! end
@ -155,7 +155,7 @@ parsoid={
==<span dir='ltr' title='x'>a</span>==
==<span dir='rtl' title='x'>b</span>==
==<i dir='rtl' title='ha'>c</i>==
!! html
!! metadata
{"toclevel":1,"level":"2","line":"<span dir=\"ltr\">a<\/span>","number":"1","index":"1","fromtitle":"Parser_test","byteoffset":0,"anchor":"a","linkAnchor":"a"}
{"toclevel":1,"level":"2","line":"<span dir=\"rtl\">b<\/span>","number":"2","index":"2","fromtitle":"Parser_test","byteoffset":39,"anchor":"b","linkAnchor":"b"}
{"toclevel":1,"level":"2","line":"<i>c<\/i>","number":"3","index":"3","fromtitle":"Parser_test","byteoffset":78,"anchor":"c","linkAnchor":"c"}
@ -174,10 +174,10 @@ parsoid={
!! wikitext
==<span><div></div></span>x==
==<span dir='ltr'><i dir='ltr'></i></span>y==
!! html/php
!! metadata/php
{"toclevel":1,"level":"2","line":"x","number":"1","index":"1","fromtitle":"Parser_test","byteoffset":0,"anchor":"x","linkAnchor":"x"}
{"toclevel":1,"level":"2","line":"<span dir=\"ltr\"><i><\/i><\/span>y","number":"2","index":"2","fromtitle":"Parser_test","byteoffset":30,"anchor":"y","linkAnchor":"y"}
!! html/parsoid
!! metadata/parsoid
{"toclevel":1,"level":"2","line":"x","number":"1","index":"1","fromtitle":"Parser_test","byteoffset":0,"anchor":"x","linkAnchor":"x"}
{"toclevel":1,"level":"2","line":"y","number":"2","index":"2","fromtitle":"Parser_test","byteoffset":30,"anchor":"y","linkAnchor":"y"}
!! end
@ -195,7 +195,7 @@ parsoid={
==[[Cat]]==
==[[Dog]]s==
==[[Cat|I love my ''cat'']]==
!! html
!! metadata
{"toclevel":1,"level":"2","line":"Cat","number":"1","index":"1","fromtitle":"Parser_test","byteoffset":0,"anchor":"Cat","linkAnchor":"Cat"}
{"toclevel":1,"level":"2","line":"Dogs","number":"2","index":"2","fromtitle":"Parser_test","byteoffset":12,"anchor":"Dogs","linkAnchor":"Dogs"}
{"toclevel":1,"level":"2","line":"I love my <i>cat<\/i>","number":"3","index":"3","fromtitle":"Parser_test","byteoffset":25,"anchor":"I_love_my_cat","linkAnchor":"I_love_my_cat"}
@ -218,7 +218,7 @@ wgFragmentMode=[ "html5", "legacy" ]
!! wikitext
===a=
=''x''=
!! html
!! metadata
{"toclevel":1,"level":"1","line":"==a","number":"1","index":"1","fromtitle":"Parser_test","byteoffset":0,"anchor":"==a","linkAnchor":"==a"}
{"toclevel":1,"level":"1","line":"<i>x<\/i>","number":"2","index":"2","fromtitle":"Parser_test","byteoffset":6,"anchor":"x","linkAnchor":"x"}
!! end
@ -258,13 +258,13 @@ parsoid={
{{1x|1=
==b==
}}
!! html/php
!! metadata/php
{"toclevel":1,"level":"2","line":"a","number":"1","index":"1","fromtitle":"Parser_test","byteoffset":0,"anchor":"a","linkAnchor":"a"}
{"toclevel":1,"level":"2","line":"b","number":"2","index":"","fromtitle":false,"byteoffset":null,"anchor":"b","linkAnchor":"b"}
!! html/parsoid
!! metadata/parsoid
{"toclevel":1,"level":"2","line":"a","number":"1","index":"1","fromtitle":"Parser_test","byteoffset":0,"anchor":"a","linkAnchor":"a"}
{"toclevel":1,"level":"2","line":"b","number":"2","index":"T-2","fromtitle":"Template:1x","byteoffset":null,"anchor":"b","linkAnchor":"b"}
!! html/parsoid+integrated
!! metadata/parsoid+integrated
{"toclevel":1,"level":"2","line":"a","number":"1","index":"1","fromtitle":"Parser_test","byteoffset":0,"anchor":"a","linkAnchor":"a"}
{"toclevel":1,"level":"2","line":"b","number":"2","index":"T-1","fromtitle":"Template:1x","byteoffset":null,"anchor":"b","linkAnchor":"b"}
!! end
@ -292,9 +292,9 @@ parsoid={
}
!! wikitext
==c<ref>d</ref>==
!! html+disabled
!! metadata+disabled
{"toclevel":1,"level":"2","line":"c<sup>&#91;1&#93;<\/sup>","number":"1","index":"1","fromtitle":"Parser_test","byteoffset":0,"anchor":"c[1]","linkAnchor":"c[1]"}
!! html/parsoid
!! metadata/parsoid
{"toclevel":1,"level":"2","line":"c<sup><span>[1]<\/span><\/sup>","number":"1","index":"1","fromtitle":"Parser_test","byteoffset":0,"anchor":"c[1]","linkAnchor":"c[1]"}
!! end
@ -314,8 +314,8 @@ parsoid={
}
!! wikitext
==c<tag>d</tag>==
!! html
!! metadata/php
{"toclevel":1,"level":"2","line":"c\n'd'\narray (\n)","number":"1","index":"1","fromtitle":"Parser_test","byteoffset":0,"anchor":"c_'d'_array_(_)","linkAnchor":"c_'d'_array_(_)"}
!! html/parsoid
!! metadata/parsoid
{"toclevel":1,"level":"2","line":"c'd'\narray (\n)","number":"1","index":"1","fromtitle":"Parser_test","byteoffset":0,"anchor":"c'd'_array_(_)","linkAnchor":"c'd'_array_(_)"}
!! end