[go: up one dir, main page]

Page MenuHomePhabricator

Custom main page title has a p and no span in it
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue:

What happens?:

HTML looks something like:

<h1 id="firstHeading" class="firstHeading mw-first-heading">
  <p>MediaWiki is a collaboration and documentation platform brought to you by a vibrant community.</p><!--__DTHASLEDECONTENT__--><!--__DTEMPTYTALKPAGE__-->
</h1>

What should have happened instead?:
The HTML expected for a heading elsewhere as with e.g. https://www.mediawiki.org/wiki/Download :

<h1 id="firstHeading" class="firstHeading mw-first-heading">
  <span class="mw-page-title-main">Download</span>
</h1>

The diff is the span with class versus the p.

Software version: 1.40.0-wmf.18 (00e0651) 16:17, 9 January 2023

Other information:
An h1 allows only phrasing content, so this also constitutes invalid HTML since a p is flow content, though of course it renders... reasonably. But also differently due to the p's margins. I had been trying to figure out why it looked different only to have my attention drawn from a different direction by someone on Discord trying to troubleshoot why their output on some page of their wiki had the expected span and thinking that https://www.mediawiki.org/wiki/MediaWiki was representative of general output for the h1 in MediaWiki.

Event Timeline

<span class="mw-page-title-main"> is added by Parser::formatPageTitle.

include/skins/Skin.php

if ( !$titleMsg->isDisabled() ) {
        $htmlTitle = $titleMsg->parse();
} else {
        $htmlTitle = $out->getPageTitle();
}

So getPageTitle here is adding the mw-page-title-main class, because that's the title formatting at the parser level. The mainpage override is a skin option, and the skin does not add this class. Still trying to figure out where the <p> is coming from. Probably from msg->parse() (update: switching the msg to use <div>, does remove the p elements....)

Can't seem to reproduce this locally yet....

TheDJ added a subscriber: matmarex.

Suspect this is due to DiscussionTools, which I do not have installed locally. The html also has DT related comments inserted, which I think is new.

<header class="mw-body-header vector-page-titlebar">
				
				    <h1 id="firstHeading" class="firstHeading mw-first-heading"><p><span>MediaWiki is a collaboration and documentation platform brought to you by a vibrant community</span>
</p><!--__DTHASLEDECONTENT__--><!--__DTEMPTYTALKPAGE__--></h1>
				
				
				        <div class="mw-indicators">
        </div>
</header>

Alternate possibility might be the header rework ? Tagging @matmarex they'll likely know

Change 880571 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/core@master] Set interface flag for the main page title message

https://gerrit.wikimedia.org/r/880571

Change 880571 merged by jenkins-bot:

[mediawiki/core@master] Set interface flag for the main page title message

https://gerrit.wikimedia.org/r/880571

This is still missing the span. If there is a reason not to add the span, that's fine, but that was not documented in this task and should be if it's deliberate.

That's deliberate, <span class="mw-page-title-main"> is only added when displaying the actual page title. That feature was added recently in T306440.

There is a task about adding a similar wrapper for pages with {{DISPLAYTITLE:}} markup: T319035: Put DISPLAYTITLE in its own span, I suppose the same thing could make sense for this case.