Support for core section heading formatting in post-cache transform

We already supported plain headings without the 'mw-headline'
wrappers, but now we need to parse the 'id' from a different
attribute.

Needed-By: If04d72f427ec3c3730e757cbb3ade8840c09f7d3
Bug: T357723
Change-Id: If85f89c40834618f23dc0ace2e599efb3b6d5ed4
This commit is contained in:
Bartosz Dziewoński 2024-02-16 17:53:51 +01:00
parent 85f75fb8ed
commit 08f61b2609
8 changed files with 189 additions and 4 deletions

View file

@ -1302,7 +1302,8 @@ class CommentParser {
// <span class="mw-headline" …>, or <hN …> in Parsoid HTML
$headline = $threadItem->getRange()->startContainer;
Assert::precondition( $headline instanceof Element, 'HeadingItem refers to an element node' );
$id = 'h-' . $this->truncateForId( $headline->getAttribute( 'id' ) ?? '' );
$id = 'h-' . $this->truncateForId( $headline->getAttribute( 'id' )
?: $headline->getAttribute( 'data-mw-anchor' ) ?? '' );
} elseif ( $threadItem instanceof ContentCommentItem ) {
$id = 'c-' . $this->truncateForId( str_replace( ' ', '_', $threadItem->getAuthor() ) ) .
'-' . $threadItem->getTimestampString();
@ -1317,7 +1318,8 @@ class CommentParser {
// <span class="mw-headline" …>, or <hN …> in Parsoid HTML
$headline = $threadItemParent->getRange()->startContainer;
Assert::precondition( $headline instanceof Element, 'HeadingItem refers to an element node' );
$id .= '-' . $this->truncateForId( $headline->getAttribute( 'id' ) ?? '' );
$id .= '-' . $this->truncateForId( $headline->getAttribute( 'id' )
?: $headline->getAttribute( 'data-mw-anchor' ) ?? '' );
} elseif ( $threadItemParent instanceof ContentCommentItem ) {
$id .= '-' . $this->truncateForId( str_replace( ' ', '_', $threadItemParent->getAuthor() ) ) .
'-' . $threadItemParent->getTimestampString();

View file

@ -340,7 +340,7 @@ class CommentUtils {
Assert::precondition( $headline !== null, 'data-mw-comment-start was attached to a heading' );
}
if ( !$headline->getAttribute( 'id' ) ) {
if ( !$headline->getAttribute( 'id' ) && !$headline->getAttribute( 'data-mw-anchor' ) ) {
// PHP HTML: Find the child with .mw-headline
$headline = DOMCompat::querySelector( $headline, '.mw-headline' );
if ( !$headline ) {

View file

@ -43,7 +43,7 @@ class ContentHeadingItem extends ContentThreadItem implements HeadingItem {
// <span class="mw-headline" …>, or <hN …> in Parsoid HTML
$headline = $this->getRange()->startContainer;
Assert::precondition( $headline instanceof Element, 'HeadingItem refers to an element node' );
$id = $headline->getAttribute( 'id' );
$id = $headline->getAttribute( 'id' ) ?: $headline->getAttribute( 'data-mw-anchor' );
if ( $id ) {
// Replace underscores with spaces to undo Sanitizer::escapeIdInternal().
// This assumes that $wgFragmentMode is [ 'html5', 'legacy' ] or [ 'html5' ],

View file

@ -7,6 +7,7 @@ use MediaWiki\Extension\DiscussionTools\CommentModifier;
use MediaWiki\Extension\DiscussionTools\ImmutableRange;
use MediaWiki\Parser\Sanitizer;
use Wikimedia\Parsoid\DOM\Element;
use Wikimedia\Parsoid\Utils\DOMCompat;
use Wikimedia\Parsoid\Utils\DOMUtils;
/**
@ -186,6 +187,21 @@ abstract class ContentThreadItem implements JsonSerializable, ThreadItem {
public function getHTML(): string {
$fragment = $this->getRange()->cloneContents();
CommentModifier::unwrapFragment( $fragment );
// Does not work: T357812
// $editsection = DOMCompat::querySelector( $fragment, 'mw\\:editsection' );
for ( $n = $fragment->firstChild; $n; $n = $n->nextSibling ) {
if ( $n instanceof Element ) {
if ( strtolower( $n->tagName ) === 'mw:editsection' ) {
$n->parentNode->removeChild( $n );
break;
}
$editsection = DOMCompat::querySelector( $n, 'mw\\:editsection' );
if ( $editsection ) {
$editsection->parentNode->removeChild( $editsection );
break;
}
}
}
return DOMUtils::getFragmentInnerHTML( $fragment );
}

View file

@ -0,0 +1,72 @@
<span data-mw-thread-id="h--2021-02-24T19:24:00.000Z"><span data-mw-comment-start="" id="h--2021-02-24T19:24:00.000Z"></span><span data-mw-comment-end="h--2021-02-24T19:24:00.000Z"></span></span><span data-mw-comment-start="" id="c-Matma_Rex-2021-02-24T19:24:00.000Z"></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>TODO: This is out of date, we no longer use OutputPageBeforeHTML, so we should really update all of the other tests instead of just this one D:
</p><p>Note:
</p>
<ul><li>No "mw-parser-output" wrapper div</li>
<li>Funky mw:editsection tags</li>
<li>'data-mw-anchor' attributes on headings</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>) <a href="https://example.org/wiki/Talk:For_parser_cache#c-Matma_Rex-2021-02-24T19:24:00.000Z" class="ext-discussiontools-init-timestamplink">19:24, 24 February 2021 (UTC)</a><span class="ext-discussiontools-init-replylink-buttons" data-mw-thread-id="c-Matma_Rex-2021-02-24T19:24:00.000Z"><span class="ext-discussiontools-init-replybutton oo-ui-widget oo-ui-widget-enabled oo-ui-buttonElement oo-ui-buttonElement-frameless oo-ui-labelElement oo-ui-flaggedElement-progressive oo-ui-buttonWidget" data-ooui='{"_":"OO.ui.ButtonWidget","rel":["nofollow"],"framed":false,"label":"(discussiontools-replybutton)","flags":["progressive"],"classes":["ext-discussiontools-init-replybutton"]}'><a role="button" tabindex="0" rel="nofollow" class="oo-ui-buttonElement-button"><span class="oo-ui-iconElement-icon oo-ui-iconElement-noIcon oo-ui-image-progressive"></span><span class="oo-ui-labelElement-label">(discussiontools-replybutton)</span><span class="oo-ui-indicatorElement-indicator oo-ui-indicatorElement-noIndicator oo-ui-image-progressive"></span></a></span><span class="ext-discussiontools-init-replylink-bracket">[</span><a class="ext-discussiontools-init-replylink-reply" role="button" tabindex="0" href="">(discussiontools-replylink)</a><span class="ext-discussiontools-init-replylink-bracket">]</span></span><span data-mw-comment-end="c-Matma_Rex-2021-02-24T19:24:00.000Z"></span>
</p>
<div class="mw-heading mw-heading2 ext-discussiontools-init-section"><span class='ext-discussiontools-init-section-subscribeButton oo-ui-widget oo-ui-widget-enabled oo-ui-buttonElement oo-ui-buttonElement-frameless oo-ui-iconElement oo-ui-labelElement oo-ui-flaggedElement-progressive oo-ui-buttonWidget' data-ooui='{"_":"OO.ui.ButtonWidget","href":"\/w\/index.php?title=Talk:For_parser_cache&amp;action=dtsubscribe&amp;commentname=h-Matma_Rex-2021-02-24T19%3A24%3A00.000Z&amp;section=Heading+with+a+%22+quote","rel":["nofollow"],"framed":false,"icon":"bellOutline","label":"(discussiontools-topicsubscription-button-subscribe-label)","title":"(discussiontools-topicsubscription-button-subscribe-tooltip)","flags":["progressive"],"classes":["ext-discussiontools-init-section-subscribeButton"]}'><a role='button' title='(discussiontools-topicsubscription-button-subscribe-tooltip)' tabindex='0' href='/w/index.php?title=Talk:For_parser_cache&amp;action=dtsubscribe&amp;commentname=h-Matma_Rex-2021-02-24T19%3A24%3A00.000Z&amp;section=Heading+with+a+%22+quote' rel='nofollow' class='oo-ui-buttonElement-button'><span class='oo-ui-iconElement-icon oo-ui-icon-bellOutline oo-ui-image-progressive'></span><span class='oo-ui-labelElement-label'>(discussiontools-topicsubscription-button-subscribe-label)</span><span class='oo-ui-indicatorElement-indicator oo-ui-indicatorElement-noIndicator oo-ui-image-progressive'></span></a></span><h2 data-mw-anchor="Heading_with_a_&quot;_quote" data-mw-fallback-anchor="Heading_with_a_.22_quote" data-mw-thread-id="h-Heading_with_a_&quot;_quote-2021-02-24T19:24:00.000Z"><span data-mw-comment-start="" id="h-Heading_with_a_&quot;_quote-2021-02-24T19:24:00.000Z"></span><span class="ext-discussiontools-init-section-subscribe mw-editsection-like"><span class="ext-discussiontools-init-section-subscribe-bracket">[</span><a href="/w/index.php?title=Talk:For_parser_cache&amp;action=dtsubscribe&amp;commentname=h-Matma_Rex-2021-02-24T19%3A24%3A00.000Z&amp;section=Heading+with+a+%22+quote" class="ext-discussiontools-init-section-subscribe-link" role="button" tabindex="0" title="(discussiontools-topicsubscription-button-subscribe-tooltip)">(discussiontools-topicsubscription-button-subscribe)</a><span class="ext-discussiontools-init-section-subscribe-bracket">]</span></span>Heading with a " quote<mw:editsection page="Talk:For parser cache" section="1">Heading with a " quote</mw:editsection><span data-mw-comment-end="h-Heading_with_a_&quot;_quote-2021-02-24T19:24:00.000Z"></span></h2><div class="ext-discussiontools-init-section-bar"><div class="ext-discussiontools-init-section-metadata"><span class='ext-discussiontools-init-section-metaitem ext-discussiontools-init-section-timestampLabel'>(discussiontools-topicheader-latestcomment: <a href="#c-Matma_Rex-2021-02-24T19:24:00.000Z-Heading_with_a_&quot;_quote">1614194640</a>)</span><span class='ext-discussiontools-init-section-metaitem ext-discussiontools-init-section-commentCountLabel'>(discussiontools-topicheader-commentcount: 1)</span><span class='ext-discussiontools-init-section-metaitem ext-discussiontools-init-section-authorCountLabel'>(discussiontools-topicheader-authorcount: 1)</span></div><div class="ext-discussiontools-init-section-actions"></div></div></div>
<p><span data-mw-comment-start="" id="c-Matma_Rex-2021-02-24T19:24:00.000Z-Heading_with_a_&quot;_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>) <a href="https://example.org/wiki/Talk:For_parser_cache#c-Matma_Rex-2021-02-24T19:24:00.000Z-Heading_with_a_&quot;_quote" class="ext-discussiontools-init-timestamplink">19:24, 24 February 2021 (UTC)</a><span class="ext-discussiontools-init-replylink-buttons" data-mw-thread-id="c-Matma_Rex-2021-02-24T19:24:00.000Z-Heading_with_a_&quot;_quote"><span class="ext-discussiontools-init-replybutton oo-ui-widget oo-ui-widget-enabled oo-ui-buttonElement oo-ui-buttonElement-frameless oo-ui-labelElement oo-ui-flaggedElement-progressive oo-ui-buttonWidget" data-ooui='{"_":"OO.ui.ButtonWidget","rel":["nofollow"],"framed":false,"label":"(discussiontools-replybutton)","flags":["progressive"],"classes":["ext-discussiontools-init-replybutton"]}'><a role="button" tabindex="0" rel="nofollow" class="oo-ui-buttonElement-button"><span class="oo-ui-iconElement-icon oo-ui-iconElement-noIcon oo-ui-image-progressive"></span><span class="oo-ui-labelElement-label">(discussiontools-replybutton)</span><span class="oo-ui-indicatorElement-indicator oo-ui-indicatorElement-noIndicator oo-ui-image-progressive"></span></a></span><span class="ext-discussiontools-init-replylink-bracket">[</span><a class="ext-discussiontools-init-replylink-reply" role="button" tabindex="0" href="">(discussiontools-replylink)</a><span class="ext-discussiontools-init-replylink-bracket">]</span></span><span data-mw-comment-end="c-Matma_Rex-2021-02-24T19:24:00.000Z-Heading_with_a_&quot;_quote"></span>
</p>
<pre>
newestComment: {
"id": "c-Matma_Rex-2021-02-24T19:24:00.000Z-Heading_with_a_\"_quote",
"timestamp": "2021-02-24T19:24:00.000Z",
"author": "Matma Rex",
"heading": {
"headingLevel": 2,
"name": "h-Matma_Rex-2021-02-24T19:24:00.000Z",
"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"
],
"text": "Heading with a \" quote",
"linkableTitle": "Heading with a \" quote"
}
}
hasLedeContent
hasCommentsInLedeContent
{
"wgDiscussionToolsPageThreads": [
{
"headingLevel": null,
"name": "h-Matma_Rex-2021-02-24T19:24:00.000Z",
"type": "heading",
"level": 0,
"id": "h--2021-02-24T19:24:00.000Z",
"replies": [
{
"timestamp": "2021-02-24T19:24:00.000Z",
"author": "Matma Rex",
"type": "comment",
"level": 1,
"id": "c-Matma_Rex-2021-02-24T19:24:00.000Z",
"replies": []
}
]
},
{
"headingLevel": 2,
"name": "h-Matma_Rex-2021-02-24T19:24:00.000Z",
"type": "heading",
"level": 0,
"id": "h-Heading_with_a_\"_quote-2021-02-24T19:24:00.000Z",
"replies": [
{
"timestamp": "2021-02-24T19:24:00.000Z",
"author": "Matma Rex",
"type": "comment",
"level": 1,
"id": "c-Matma_Rex-2021-02-24T19:24:00.000Z-Heading_with_a_\"_quote",
"replies": []
}
]
}
]
}
</pre>

View file

@ -0,0 +1,72 @@
<span data-mw-thread-id="h--2021-02-24T19:24:00.000Z"><span data-mw-comment-start="" id="h--2021-02-24T19:24:00.000Z"></span><span data-mw-comment-end="h--2021-02-24T19:24:00.000Z"></span></span><span data-mw-comment-start="" id="c-Matma_Rex-2021-02-24T19:24:00.000Z"></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>TODO: This is out of date, we no longer use OutputPageBeforeHTML, so we should really update all of the other tests instead of just this one D:
</p><p>Note:
</p>
<ul><li>No "mw-parser-output" wrapper div</li>
<li>Funky mw:editsection tags</li>
<li>'data-mw-anchor' attributes on headings</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>) <a href="https://example.org/wiki/Talk:For_parser_cache#c-Matma_Rex-2021-02-24T19:24:00.000Z" class="ext-discussiontools-init-timestamplink">19:24, 24 February 2021 (UTC)</a><span class="ext-discussiontools-init-replylink-buttons" data-mw-thread-id="c-Matma_Rex-2021-02-24T19:24:00.000Z"><span class="ext-discussiontools-init-replybutton oo-ui-widget oo-ui-widget-enabled oo-ui-buttonElement oo-ui-buttonElement-frameless oo-ui-iconElement oo-ui-labelElement oo-ui-flaggedElement-progressive oo-ui-buttonWidget" data-ooui='{"_":"OO.ui.ButtonWidget","rel":["nofollow"],"framed":false,"icon":"share","label":"(discussiontools-replybutton)","flags":["progressive"],"classes":["ext-discussiontools-init-replybutton"]}'><a role="button" tabindex="0" rel="nofollow" class="oo-ui-buttonElement-button"><span class="oo-ui-iconElement-icon oo-ui-icon-share oo-ui-image-progressive"></span><span class="oo-ui-labelElement-label">(discussiontools-replybutton)</span><span class="oo-ui-indicatorElement-indicator oo-ui-indicatorElement-noIndicator oo-ui-image-progressive"></span></a></span><span class="ext-discussiontools-init-replylink-bracket">[</span><a class="ext-discussiontools-init-replylink-reply" role="button" tabindex="0" href="">(discussiontools-replylink)</a><span class="ext-discussiontools-init-replylink-bracket">]</span></span><span data-mw-comment-end="c-Matma_Rex-2021-02-24T19:24:00.000Z"></span>
</p>
<div class="mw-heading mw-heading2 ext-discussiontools-init-section"><h2 data-mw-anchor="Heading_with_a_&quot;_quote" data-mw-fallback-anchor="Heading_with_a_.22_quote" data-mw-thread-id="h-Heading_with_a_&quot;_quote-2021-02-24T19:24:00.000Z"><span data-mw-comment-start="" id="h-Heading_with_a_&quot;_quote-2021-02-24T19:24:00.000Z"></span><span class="ext-discussiontools-init-section-subscribe mw-editsection-like"><span class="ext-discussiontools-init-section-subscribe-bracket">[</span><a href="/w/index.php?title=Talk:For_parser_cache&amp;action=dtsubscribe&amp;commentname=h-Matma_Rex-2021-02-24T19%3A24%3A00.000Z&amp;section=Heading+with+a+%22+quote" class="ext-discussiontools-init-section-subscribe-link" role="button" tabindex="0" title="(discussiontools-topicsubscription-button-subscribe-tooltip)">(discussiontools-topicsubscription-button-subscribe)</a><span class="ext-discussiontools-init-section-subscribe-bracket">]</span></span>Heading with a " quote<mw:editsection page="Talk:For parser cache" section="1">Heading with a " quote</mw:editsection><span data-mw-comment-end="h-Heading_with_a_&quot;_quote-2021-02-24T19:24:00.000Z"></span></h2><span class='ext-discussiontools-init-section-overflowMenuButton oo-ui-widget oo-ui-widget-enabled oo-ui-buttonElement oo-ui-buttonElement-frameless oo-ui-iconElement oo-ui-buttonWidget' data-ooui='{"_":"OO.ui.ButtonMenuSelectWidget","rel":["nofollow"],"framed":false,"icon":"ellipsis","data":{"itemConfigs":[{"id":"edit","data":{"id":"edit"},"icon":"edit","label":"a label"}],"resourceLoaderModules":[]},"classes":["ext-discussiontools-init-section-overflowMenuButton"]}'><a role='button' tabindex='0' rel='nofollow' class='oo-ui-buttonElement-button'><span class='oo-ui-iconElement-icon oo-ui-icon-ellipsis'></span><span class='oo-ui-labelElement-label'></span><span class='oo-ui-indicatorElement-indicator oo-ui-indicatorElement-noIndicator'></span></a></span><div class="ext-discussiontools-init-section-bar"><div class="ext-discussiontools-init-section-metadata"><span class='ext-discussiontools-init-section-metaitem ext-discussiontools-init-section-timestampLabel'>(discussiontools-topicheader-latestcomment: <a href="#c-Matma_Rex-2021-02-24T19:24:00.000Z-Heading_with_a_&quot;_quote">1614194640</a>)</span><span class='ext-discussiontools-init-section-metaitem ext-discussiontools-init-section-commentCountLabel'>(discussiontools-topicheader-commentcount: 1)</span><span class='ext-discussiontools-init-section-metaitem ext-discussiontools-init-section-authorCountLabel'>(discussiontools-topicheader-authorcount: 1)</span></div><div class="ext-discussiontools-init-section-actions"><span class='ext-discussiontools-init-section-subscribeButton oo-ui-widget oo-ui-widget-enabled oo-ui-buttonElement oo-ui-buttonElement-frameless oo-ui-iconElement oo-ui-labelElement oo-ui-flaggedElement-progressive oo-ui-buttonWidget' data-ooui='{"_":"OO.ui.ButtonWidget","href":"\/w\/index.php?title=Talk:For_parser_cache&amp;action=dtsubscribe&amp;commentname=h-Matma_Rex-2021-02-24T19%3A24%3A00.000Z&amp;section=Heading+with+a+%22+quote","rel":["nofollow"],"framed":false,"icon":"bellOutline","label":"(discussiontools-topicsubscription-button-subscribe-label)","title":"(discussiontools-topicsubscription-button-subscribe-tooltip)","flags":["progressive"],"classes":["ext-discussiontools-init-section-subscribeButton"]}'><a role='button' title='(discussiontools-topicsubscription-button-subscribe-tooltip)' tabindex='0' href='/w/index.php?title=Talk:For_parser_cache&amp;action=dtsubscribe&amp;commentname=h-Matma_Rex-2021-02-24T19%3A24%3A00.000Z&amp;section=Heading+with+a+%22+quote' rel='nofollow' class='oo-ui-buttonElement-button'><span class='oo-ui-iconElement-icon oo-ui-icon-bellOutline oo-ui-image-progressive'></span><span class='oo-ui-labelElement-label'>(discussiontools-topicsubscription-button-subscribe-label)</span><span class='oo-ui-indicatorElement-indicator oo-ui-indicatorElement-noIndicator oo-ui-image-progressive'></span></a></span></div></div></div>
<p><span data-mw-comment-start="" id="c-Matma_Rex-2021-02-24T19:24:00.000Z-Heading_with_a_&quot;_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>) <a href="https://example.org/wiki/Talk:For_parser_cache#c-Matma_Rex-2021-02-24T19:24:00.000Z-Heading_with_a_&quot;_quote" class="ext-discussiontools-init-timestamplink">19:24, 24 February 2021 (UTC)</a><span class="ext-discussiontools-init-replylink-buttons" data-mw-thread-id="c-Matma_Rex-2021-02-24T19:24:00.000Z-Heading_with_a_&quot;_quote"><span class="ext-discussiontools-init-replybutton oo-ui-widget oo-ui-widget-enabled oo-ui-buttonElement oo-ui-buttonElement-frameless oo-ui-iconElement oo-ui-labelElement oo-ui-flaggedElement-progressive oo-ui-buttonWidget" data-ooui='{"_":"OO.ui.ButtonWidget","rel":["nofollow"],"framed":false,"icon":"share","label":"(discussiontools-replybutton)","flags":["progressive"],"classes":["ext-discussiontools-init-replybutton"]}'><a role="button" tabindex="0" rel="nofollow" class="oo-ui-buttonElement-button"><span class="oo-ui-iconElement-icon oo-ui-icon-share oo-ui-image-progressive"></span><span class="oo-ui-labelElement-label">(discussiontools-replybutton)</span><span class="oo-ui-indicatorElement-indicator oo-ui-indicatorElement-noIndicator oo-ui-image-progressive"></span></a></span><span class="ext-discussiontools-init-replylink-bracket">[</span><a class="ext-discussiontools-init-replylink-reply" role="button" tabindex="0" href="">(discussiontools-replylink)</a><span class="ext-discussiontools-init-replylink-bracket">]</span></span><span data-mw-comment-end="c-Matma_Rex-2021-02-24T19:24:00.000Z-Heading_with_a_&quot;_quote"></span>
</p>
<pre>
newestComment: {
"id": "c-Matma_Rex-2021-02-24T19:24:00.000Z-Heading_with_a_\"_quote",
"timestamp": "2021-02-24T19:24:00.000Z",
"author": "Matma Rex",
"heading": {
"headingLevel": 2,
"name": "h-Matma_Rex-2021-02-24T19:24:00.000Z",
"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"
],
"text": "Heading with a \" quote",
"linkableTitle": "Heading with a \" quote"
}
}
hasLedeContent
hasCommentsInLedeContent
{
"wgDiscussionToolsPageThreads": [
{
"headingLevel": null,
"name": "h-Matma_Rex-2021-02-24T19:24:00.000Z",
"type": "heading",
"level": 0,
"id": "h--2021-02-24T19:24:00.000Z",
"replies": [
{
"timestamp": "2021-02-24T19:24:00.000Z",
"author": "Matma Rex",
"type": "comment",
"level": 1,
"id": "c-Matma_Rex-2021-02-24T19:24:00.000Z",
"replies": []
}
]
},
{
"headingLevel": 2,
"name": "h-Matma_Rex-2021-02-24T19:24:00.000Z",
"type": "heading",
"level": 0,
"id": "h-Heading_with_a_\"_quote-2021-02-24T19:24:00.000Z",
"replies": [
{
"timestamp": "2021-02-24T19:24:00.000Z",
"author": "Matma Rex",
"type": "comment",
"level": 1,
"id": "c-Matma_Rex-2021-02-24T19:24:00.000Z-Heading_with_a_\"_quote",
"replies": []
}
]
}
]
}
</pre>

View file

@ -0,0 +1,12 @@
<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>TODO: This is out of date, we no longer use OutputPageBeforeHTML, so we should really update all of the other tests instead of just this one D:
</p><p>Note:
</p>
<ul><li>No "mw-parser-output" wrapper div</li>
<li>Funky mw:editsection tags</li>
<li>'data-mw-anchor' attributes on headings</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 data-mw-anchor="Heading_with_a_&quot;_quote" data-mw-fallback-anchor="Heading_with_a_.22_quote">Heading with a " quote<mw:editsection page="Talk:For parser cache" section="1">Heading with a &quot; 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

@ -142,6 +142,17 @@
"config": "../data/enwiki-config.json",
"data": "../data/enwiki-data.json"
},
{
"name": "For parser cache (new)",
"title": "Talk:For parser cache",
"dom": "cases/for-parser-cache-new/for-parser-cache-new.html",
"expected": {
"desktop": "cases/for-parser-cache-new/for-parser-cache-new-formatted-desktop.html",
"mobile": "cases/for-parser-cache-new/for-parser-cache-new-formatted-mobile.html"
},
"config": "../data/enwiki-config.json",
"data": "../data/enwiki-data.json"
},
{
"name": "tracked template",
"title": "Commons talk:SPARQL query service",