Merge "CommentFormatter: Fix inserting placeholder heading marker"

This commit is contained in:
jenkins-bot 2021-02-24 20:50:51 +00:00 committed by Gerrit Code Review
commit 13d50c7e55
6 changed files with 30 additions and 3 deletions

View file

@ -99,7 +99,7 @@ class CommentFormatter {
// Create a dummy node to attach data to. // Create a dummy node to attach data to.
if ( $threadItem instanceof HeadingItem && $threadItem->isPlaceholderHeading() ) { if ( $threadItem instanceof HeadingItem && $threadItem->isPlaceholderHeading() ) {
$node = $doc->createElement( 'span' ); $node = $doc->createElement( 'span' );
$container->firstChild->insertBefore( $node, $container->firstChild->firstChild ); $container->insertBefore( $node, $container->firstChild );
$threadItem->setRange( new ImmutableRange( $node, 0, $node, 0 ) ); $threadItem->setRange( new ImmutableRange( $node, 0, $node, 0 ) );
} }

View file

@ -1,4 +1,4 @@
<div class="mw-parser-output"><span data-mw-comment='{"type":"heading","level":0,"id":"h||2020-02-20T21:53:00.000Z","replies":["c|Abdeldjalil09|2020-02-20T21:53:00.000Z"],"headingLevel":99,"placeholderHeading":true}'><span data-mw-comment-start="h||2020-02-20T21:53:00.000Z"></span><span data-mw-comment-end="h||2020-02-20T21:53:00.000Z"></span></span><div style="position:absolute; z-index:100; left:46px; top:13px;" class="metadata" id="administrator"> <span data-mw-comment='{"type":"heading","level":0,"id":"h||2020-02-20T21:53:00.000Z","replies":["c|Abdeldjalil09|2020-02-20T21:53:00.000Z"],"headingLevel":99,"placeholderHeading":true}'><span data-mw-comment-start="h||2020-02-20T21:53:00.000Z"></span><span data-mw-comment-end="h||2020-02-20T21:53:00.000Z"></span></span><div class="mw-parser-output"><div style="position:absolute; z-index:100; left:46px; top:13px;" class="metadata" id="administrator">
<div class="noresize"><map name="ImageMap_45b431928ac34195"><span data-mw-comment-start="c|Abdeldjalil09|2020-02-20T21:53:00.000Z"></span><area href="//ar.wikipedia.org/wiki/%D9%88%D9%8A%D9%83%D9%8A%D8%A8%D9%8A%D8%AF%D9%8A%D8%A7:%D9%85%D8%AD%D8%B1%D8%B1%D9%88%D9%86" shape="rect" coords="0,0,145,145" alt="هذا المستخدم محرر" title="هذا المستخدم محرر"/></map><img alt="Wikipedia Autopatrolled.svg" src="//upload.wikimedia.org/wikipedia/commons/thumb/a/a2/Wikipedia_Autopatrolled.svg/29px-Wikipedia_Autopatrolled.svg.png" decoding="async" width="29" height="29" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/a/a2/Wikipedia_Autopatrolled.svg/44px-Wikipedia_Autopatrolled.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/a/a2/Wikipedia_Autopatrolled.svg/58px-Wikipedia_Autopatrolled.svg.png 2x" data-file-width="200" data-file-height="200" usemap="#ImageMap_45b431928ac34195"/></div> <div class="noresize"><map name="ImageMap_45b431928ac34195"><span data-mw-comment-start="c|Abdeldjalil09|2020-02-20T21:53:00.000Z"></span><area href="//ar.wikipedia.org/wiki/%D9%88%D9%8A%D9%83%D9%8A%D8%A8%D9%8A%D8%AF%D9%8A%D8%A7:%D9%85%D8%AD%D8%B1%D8%B1%D9%88%D9%86" shape="rect" coords="0,0,145,145" alt="هذا المستخدم محرر" title="هذا المستخدم محرر"/></map><img alt="Wikipedia Autopatrolled.svg" src="//upload.wikimedia.org/wikipedia/commons/thumb/a/a2/Wikipedia_Autopatrolled.svg/29px-Wikipedia_Autopatrolled.svg.png" decoding="async" width="29" height="29" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/a/a2/Wikipedia_Autopatrolled.svg/44px-Wikipedia_Autopatrolled.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/a/a2/Wikipedia_Autopatrolled.svg/58px-Wikipedia_Autopatrolled.svg.png 2x" data-file-width="200" data-file-height="200" usemap="#ImageMap_45b431928ac34195"/></div>
</div> </div>
<div style="width:100%;border:none;float:right;"> <div style="width:100%;border:none;float:right;">

View file

@ -0,0 +1,10 @@
<span data-mw-comment-start="c|Matma Rex|2021-02-24T19:24:00.000Z"></span><span data-mw-comment='{"type":"heading","level":0,"id":"h||2021-02-24T19:24:00.000Z","replies":["c|Matma Rex|2021-02-24T19:24:00.000Z"],"headingLevel":99,"placeholderHeading":true}'><span data-mw-comment-start="h||2021-02-24T19:24:00.000Z"></span><span data-mw-comment-end="h||2021-02-24T19:24:00.000Z"></span></span><style data-mw-deduplicate="TemplateStyles:r3303">.mw-parser-output .color-purple{color:purple}</style><div class="color-purple">This page demonstrates some quirks of raw HTML generated in ParserOutput, which gets saved to the parser cache and which we operate on in the ParserAfterTidy hook. Most other test cases are using the final HTML returned by ParserOutput::getText(), which we operate on in the OutputPageBeforeHTML hook.</div>
<p>Note:
</p>
<ul><li>No "mw-parser-output" wrapper div</li>
<li>Funky mw:editsection tags</li></ul>
<p><a href="/wiki/User:Matma_Rex" title="User:Matma Rex">Matma Rex</a> (<a href="/wiki/User_talk:Matma_Rex" title="User talk:Matma Rex"><font color="green"><i>talk</i></font></a>) 19:24, 24 February 2021 (UTC)<span class="dt-init-replylink-buttons"><span class="dt-init-replylink-bracket">[</span><a class="dt-init-replylink-reply" role="button" tabindex="0" data-mw-comment='{"type":"comment","level":1,"id":"c|Matma Rex|2021-02-24T19:24:00.000Z","replies":[],"timestamp":"2021-02-24T19:24:00.000Z","author":"Matma Rex"}'>reply</a><span class="dt-init-replylink-bracket">]</span></span><span data-mw-comment-end="c|Matma Rex|2021-02-24T19:24:00.000Z"></span>
</p>
<h2><span id="Heading_with_a_.22_quote"></span><span class="mw-headline" id='Heading_with_a_"_quote' data-mw-comment='{"type":"heading","level":0,"id":"h|Heading_with_a_\"_quote|2021-02-24T19:24:00.000Z","replies":["c|Matma Rex|2021-02-24T19:24:00.000Z|Heading_with_a_\"_quote"],"headingLevel":2,"placeholderHeading":false}'><span data-mw-comment-start='h|Heading_with_a_"_quote|2021-02-24T19:24:00.000Z'></span>Heading with a " quote<span data-mw-comment-end='h|Heading_with_a_"_quote|2021-02-24T19:24:00.000Z'></span></span><mw:editsection page="Talk:For parser cache" section="1">Heading with a " quote</mw:editsection></h2>
<p><span data-mw-comment-start='c|Matma Rex|2021-02-24T19:24:00.000Z|Heading_with_a_"_quote'></span>Test. <a href="/wiki/User:Matma_Rex" title="User:Matma Rex">Matma Rex</a> (<a href="/wiki/User_talk:Matma_Rex" title="User talk:Matma Rex"><font color="green"><i>talk</i></font></a>) 19:24, 24 February 2021 (UTC)<span class="dt-init-replylink-buttons"><span class="dt-init-replylink-bracket">[</span><a class="dt-init-replylink-reply" role="button" tabindex="0" data-mw-comment='{"type":"comment","level":1,"id":"c|Matma Rex|2021-02-24T19:24:00.000Z|Heading_with_a_\"_quote","replies":[],"timestamp":"2021-02-24T19:24:00.000Z","author":"Matma Rex"}'>reply</a><span class="dt-init-replylink-bracket">]</span></span><span data-mw-comment-end='c|Matma Rex|2021-02-24T19:24:00.000Z|Heading_with_a_"_quote'></span>
</p>

View file

@ -0,0 +1,10 @@
<style data-mw-deduplicate="TemplateStyles:r3303">.mw-parser-output .color-purple{color:purple}</style><div class="color-purple">This page demonstrates some quirks of raw HTML generated in ParserOutput, which gets saved to the parser cache and which we operate on in the ParserAfterTidy hook. Most other test cases are using the final HTML returned by ParserOutput::getText(), which we operate on in the OutputPageBeforeHTML hook.</div>
<p>Note:
</p>
<ul><li>No "mw-parser-output" wrapper div</li>
<li>Funky mw:editsection tags</li></ul>
<p><a href="/wiki/User:Matma_Rex" title="User:Matma Rex">Matma Rex</a> (<a href="/wiki/User_talk:Matma_Rex" title="User talk:Matma Rex"><font color="green"><i>talk</i></font></a>) 19:24, 24 February 2021 (UTC)
</p>
<h2><span id="Heading_with_a_.22_quote"></span><span class="mw-headline" id="Heading_with_a_&quot;_quote">Heading with a " quote</span><mw:editsection page="Talk:For parser cache" section="1">Heading with a " quote</mw:editsection></h2>
<p>Test. <a href="/wiki/User:Matma_Rex" title="User:Matma Rex">Matma Rex</a> (<a href="/wiki/User_talk:Matma_Rex" title="User talk:Matma Rex"><font color="green"><i>talk</i></font></a>) 19:24, 24 February 2021 (UTC)
</p>

View file

@ -54,5 +54,12 @@
"expected": "cases/signatures-funny/signatures-funny-formattedreply.html", "expected": "cases/signatures-funny/signatures-funny-formattedreply.html",
"config": "../data/enwiki-config.json", "config": "../data/enwiki-config.json",
"data": "../data/enwiki-data.json" "data": "../data/enwiki-data.json"
},
{
"name": "Signatures in funny places",
"dom": "cases/for-parser-cache/for-parser-cache.html",
"expected": "cases/for-parser-cache/for-parser-cache-formattedreply.html",
"config": "../data/enwiki-config.json",
"data": "../data/enwiki-data.json"
} }
] ]

View file

@ -1,4 +1,4 @@
<div class="mw-parser-output"><span data-mw-comment='{"type":"heading","level":0,"id":"h||2020-04-09T22:31:00.000Z","replies":["c|PPelberg (WMF)|2020-04-09T22:31:00.000Z","c|PPelberg (WMF)|2020-04-09T22:31:00.000Z|1","c|PPelberg (WMF)|2020-04-09T22:31:00.000Z|2","c|PPelberg (WMF)|2020-04-09T22:31:00.000Z|3","c|PPelberg (WMF)|2020-04-09T22:31:00.000Z|4","c|PPelberg (WMF)|2020-04-09T22:31:00.000Z|5","c|PPelberg (WMF)|2020-04-09T22:31:00.000Z|6"],"headingLevel":99,"placeholderHeading":true}'><span data-mw-comment-start="h||2020-04-09T22:31:00.000Z"></span><span data-mw-comment-end="h||2020-04-09T22:31:00.000Z"></span></span><p><span data-mw-comment-start="c|PPelberg (WMF)|2020-04-09T22:31:00.000Z"></span>Is het niet handig om een sectie "nieuws/aankondiginen" op op te nemen? <a href="//nl.wikipedia.org/wiki/Gebruiker:PPelberg_(WMF)" title="Gebruiker:PPelberg (WMF)">PPelberg (WMF)</a> (<a href="//nl.wikipedia.org/wiki/Overleg_gebruiker:PPelberg_(WMF)" title="Overleg gebruiker:PPelberg (WMF)">overleg</a>) 10 apr 2020 00:31 (CEST)<span class="dt-init-replylink-buttons"><span class="dt-init-replylink-bracket">[</span><a class="dt-init-replylink-reply" role="button" tabindex="0" data-mw-comment='{"type":"comment","level":1,"id":"c|PPelberg (WMF)|2020-04-09T22:31:00.000Z","replies":["c|RYasmeen (WMF)|2020-05-26T20:23:00.000Z|PPelberg (WMF)|2020-04-09T22:31:00.000Z","c|RYasmeen (WMF)|2020-05-26T21:01:00.000Z|PPelberg (WMF)|2020-04-09T22:31:00.000Z","c|RYasmeen (WMF)|2020-06-22T20:55:00.000Z|PPelberg (WMF)|2020-04-09T22:31:00.000Z","c|RYasmeen (WMF)|2020-08-07T00:23:00.000Z|PPelberg (WMF)|2020-04-09T22:31:00.000Z","c|RYasmeen (WMF)|2020-04-09T23:57:00.000Z|PPelberg (WMF)|2020-04-09T22:31:00.000Z"],"timestamp":"2020-04-09T22:31:00.000Z","author":"PPelberg (WMF)"}'>reageer</a><span class="dt-init-replylink-bracket">]</span></span><span data-mw-comment-end="c|PPelberg (WMF)|2020-04-09T22:31:00.000Z"></span> <span data-mw-comment='{"type":"heading","level":0,"id":"h||2020-04-09T22:31:00.000Z","replies":["c|PPelberg (WMF)|2020-04-09T22:31:00.000Z","c|PPelberg (WMF)|2020-04-09T22:31:00.000Z|1","c|PPelberg (WMF)|2020-04-09T22:31:00.000Z|2","c|PPelberg (WMF)|2020-04-09T22:31:00.000Z|3","c|PPelberg (WMF)|2020-04-09T22:31:00.000Z|4","c|PPelberg (WMF)|2020-04-09T22:31:00.000Z|5","c|PPelberg (WMF)|2020-04-09T22:31:00.000Z|6"],"headingLevel":99,"placeholderHeading":true}'><span data-mw-comment-start="h||2020-04-09T22:31:00.000Z"></span><span data-mw-comment-end="h||2020-04-09T22:31:00.000Z"></span></span><div class="mw-parser-output"><p><span data-mw-comment-start="c|PPelberg (WMF)|2020-04-09T22:31:00.000Z"></span>Is het niet handig om een sectie "nieuws/aankondiginen" op op te nemen? <a href="//nl.wikipedia.org/wiki/Gebruiker:PPelberg_(WMF)" title="Gebruiker:PPelberg (WMF)">PPelberg (WMF)</a> (<a href="//nl.wikipedia.org/wiki/Overleg_gebruiker:PPelberg_(WMF)" title="Overleg gebruiker:PPelberg (WMF)">overleg</a>) 10 apr 2020 00:31 (CEST)<span class="dt-init-replylink-buttons"><span class="dt-init-replylink-bracket">[</span><a class="dt-init-replylink-reply" role="button" tabindex="0" data-mw-comment='{"type":"comment","level":1,"id":"c|PPelberg (WMF)|2020-04-09T22:31:00.000Z","replies":["c|RYasmeen (WMF)|2020-05-26T20:23:00.000Z|PPelberg (WMF)|2020-04-09T22:31:00.000Z","c|RYasmeen (WMF)|2020-05-26T21:01:00.000Z|PPelberg (WMF)|2020-04-09T22:31:00.000Z","c|RYasmeen (WMF)|2020-06-22T20:55:00.000Z|PPelberg (WMF)|2020-04-09T22:31:00.000Z","c|RYasmeen (WMF)|2020-08-07T00:23:00.000Z|PPelberg (WMF)|2020-04-09T22:31:00.000Z","c|RYasmeen (WMF)|2020-04-09T23:57:00.000Z|PPelberg (WMF)|2020-04-09T22:31:00.000Z"],"timestamp":"2020-04-09T22:31:00.000Z","author":"PPelberg (WMF)"}'>reageer</a><span class="dt-init-replylink-bracket">]</span></span><span data-mw-comment-end="c|PPelberg (WMF)|2020-04-09T22:31:00.000Z"></span>
</p><p><br/> </p><p><br/>
</p> </p>
<dl><dd><dl><dd><span data-mw-comment-start="c|RYasmeen (WMF)|2020-05-26T20:23:00.000Z|PPelberg (WMF)|2020-04-09T22:31:00.000Z"></span>active editor <a href="//nl.wikipedia.org/wiki/Gebruiker:RYasmeen_(WMF)" title="Gebruiker:RYasmeen (WMF)">RYasmeen (WMF)</a> (<a href="//nl.wikipedia.org/wiki/Overleg_gebruiker:RYasmeen_(WMF)#top" title="Overleg gebruiker:RYasmeen (WMF)">overleg</a>) 26 mei 2020 22:23 (CEST)<span class="dt-init-replylink-buttons"><span class="dt-init-replylink-bracket">[</span><a class="dt-init-replylink-reply" role="button" tabindex="0" data-mw-comment='{"type":"comment","level":3,"id":"c|RYasmeen (WMF)|2020-05-26T20:23:00.000Z|PPelberg (WMF)|2020-04-09T22:31:00.000Z","replies":["c|RYasmeen (WMF)|2020-05-26T20:32:00.000Z|RYasmeen (WMF)|2020-05-26T20:23:00.000Z","c|RYasmeen (WMF)|2020-05-28T22:05:00.000Z|RYasmeen (WMF)|2020-05-26T20:23:00.000Z","c|RYasmeen (WMF)|2020-07-29T02:21:00.000Z|RYasmeen (WMF)|2020-05-26T20:23:00.000Z","c|RYasmeen (WMF)|2020-11-18T00:15:00.000Z|RYasmeen (WMF)|2020-05-26T20:23:00.000Z"],"timestamp":"2020-05-26T20:23:00.000Z","author":"RYasmeen (WMF)"}'>reageer</a><span class="dt-init-replylink-bracket">]</span></span><span data-mw-comment-end="c|RYasmeen (WMF)|2020-05-26T20:23:00.000Z|PPelberg (WMF)|2020-04-09T22:31:00.000Z"></span> <dl><dd><dl><dd><span data-mw-comment-start="c|RYasmeen (WMF)|2020-05-26T20:23:00.000Z|PPelberg (WMF)|2020-04-09T22:31:00.000Z"></span>active editor <a href="//nl.wikipedia.org/wiki/Gebruiker:RYasmeen_(WMF)" title="Gebruiker:RYasmeen (WMF)">RYasmeen (WMF)</a> (<a href="//nl.wikipedia.org/wiki/Overleg_gebruiker:RYasmeen_(WMF)#top" title="Overleg gebruiker:RYasmeen (WMF)">overleg</a>) 26 mei 2020 22:23 (CEST)<span class="dt-init-replylink-buttons"><span class="dt-init-replylink-bracket">[</span><a class="dt-init-replylink-reply" role="button" tabindex="0" data-mw-comment='{"type":"comment","level":3,"id":"c|RYasmeen (WMF)|2020-05-26T20:23:00.000Z|PPelberg (WMF)|2020-04-09T22:31:00.000Z","replies":["c|RYasmeen (WMF)|2020-05-26T20:32:00.000Z|RYasmeen (WMF)|2020-05-26T20:23:00.000Z","c|RYasmeen (WMF)|2020-05-28T22:05:00.000Z|RYasmeen (WMF)|2020-05-26T20:23:00.000Z","c|RYasmeen (WMF)|2020-07-29T02:21:00.000Z|RYasmeen (WMF)|2020-05-26T20:23:00.000Z","c|RYasmeen (WMF)|2020-11-18T00:15:00.000Z|RYasmeen (WMF)|2020-05-26T20:23:00.000Z"],"timestamp":"2020-05-26T20:23:00.000Z","author":"RYasmeen (WMF)"}'>reageer</a><span class="dt-init-replylink-bracket">]</span></span><span data-mw-comment-end="c|RYasmeen (WMF)|2020-05-26T20:23:00.000Z|PPelberg (WMF)|2020-04-09T22:31:00.000Z"></span>