Page MenuHomePhabricator

Add markup to article headings to distinguish between the namespace and the title
Closed, ResolvedPublic

Description

The Editing Team want to be able to style the namespace separate from the heading in certain circumstances, as part of their talk pages project work. Example:

image.png (175×609 px, 46 KB)

(see T299814)

In order to do this we need some additional markup in the h1.firstHeading, at least one additional span.

Our proposal is to just wrap the namespace name in a span for now, as this will result in no changes to main article HTML.

Note: This change is not proposing any visual change to page headings. That will be done in much more limited and scoped places such as T299814, with staged rollouts and user options.


Final markup

Pages outside of the main namespace now have the following markup in their <h1> page titles, using 'Talk:Hello' as an example:

<h1>
  <span class="mw-page-title-namespace">Talk</span>
  <span class="mw-page-title-separator">:</span>
  <span class="mw-page-title-main">Hello</span>
</h1>

(line breaks and spaces added for readability)

Pages in the main namespace only have the last part, e.g. for 'Hello':

<h1>
  <span class="mw-page-title-main">Hello</span>
</h1>

The new markup is not added when the title is overridden using the wikitext {{DISPLAYTITLE:…}} or -{T|…}- forms. This may be improved in the future.

Related Objects

Event Timeline

Esanders updated the task description. (Show Details)

Change 780895 had a related patch set uploaded (by Esanders; author: Esanders):

[mediawiki/core@master] Wrap article title namespace in a <span> for selective styling in skins

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

@Whatamidoing-WMF This might be appropriate for tech news. It's a pretty small change, but if there is some gadget out there that adds <span>s to the main <h1>, then styles it with a too-generic selector like h1 > span then potentially this change could require some updates to that.

Test wiki created on Patch demo by JKlein (WMF) using patch(es) linked to this task:
https://patchdemo.wmflabs.org/wikis/65d33f5a9f/w/

@Jdlrobson I think it'd be a step towards it, at least from a display perspective -- it wouldn't help with the referenced translation concerns at all. It'd let the communities override the display via CSS, certainly, either to hide it entirely or to relocate it a bit. Though, that would make it easier to realize @Quiddity's concern about breaking the copy-paste workflows, but at least it'd be a community-chosen thing that we wouldn't have inherently pushed upon people (and e.g. in DiscussionTools we're making it *look* like there's a space, but it'll still copy just fine).

Separating namespace and base page name in HTML is an awesome addition. I am commenting here instead of T236215 since this is tagged for MediaWiki-Core-Skin-Architecture.

but at least it'd be a community-chosen thing that we wouldn't have inherently pushed upon people (and e.g. in DiscussionTools we're making it *look* like there's a space, but it'll still copy just fine).

A potential solution while retaining the current behavior can be adding an option under Special:Preferences > Appearance > Advanced options to allow different options to handle namespace display, like how link underlining and hidden categories are handled with core by CSS.

However in a long term, it would be great to be able to access both of them in Mustache instead of having them together as html-title.
The challenge however might be how would it inform Mustache to not render the namespace. In some cases such as Special pages, namespace is not rendered, along with some other possible cases that I might not know of. The Foreground skin which is used on Wikiapiary currently render namespace in a different location than the title.

Change 810114 had a related patch set uploaded (by C. Scott Ananian; author: C. Scott Ananian):

[mediawiki/core@master] WIP: Don't allow {{DISPLAYTITLE}} and -{T|..}- to override namespace l10n

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

matmarex removed a project: Patch-For-Review.
matmarex added a subscriber: cscott.

We discovered that there are many cases where the first approach in @Esanders's patch didn't work. Obviously there's a problem when the title is overridden via DISPLAYTITLE, but also e.g. when language converter is active, or on translateable pages, or on user and user talk pages with gendered namespaces.

@cscott's patch above is a large refactoring and it's unclear when it would be possible to finish it and get it merged.

I'm going to try to make a smaller patch, that gets as many of these edge cases as feasible, and document which ones are not feasible. Hopefully this is something we can write, review and merge in a week or two at most.

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

[mediawiki/core@master] Add markup to page titles to distinguish the namespace and the main text

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

Change 780895 abandoned by Esanders:

[mediawiki/core@master] Wrap article title namespace in a <span> for selective styling in skins

Reason:

See I62b17ef22de3606d736e6c261e542a34b58b5a05 for new approach

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

Change 821353 merged by jenkins-bot:

[mediawiki/core@master] Add markup to page titles to distinguish the namespace and the main text

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

I am wondering if we should announce this in Tech News, or maybe some other venue?

The change is motivated by a desire to style the titles differently on talk pages in the DiscussionTools extension (T313636), but it could also be used for other things:

  • Language-specific tweaks (e.g. adding typographically-correct spaces around the colon separator: T249149, or replacing it with a different character: T36295)
  • Site-specific tweaks (e.g. de-emphasize or emphasize specific namespaces like 'Draft': T62973 / T236215)

On the other hand, the implementation is somewhat hacky and may still change, and we may also want to wait a little before we announce it more widely so that we can do the DiscussionTools thing first.

I am wondering if we should announce this in Tech News, or maybe some other venue?

I'm moving this to "Blocked" and assigning it to me so that I can be held accountable to talking with @Whatamidoing-WMF about this and deciding how we'll go about publicizing this change.

As this will probably not be ready for a few weeks, it shouldn't go in Tech News for 22 August. At a future date, the text for Tech/New could look something like this:

The Beta Feature for [[mw:Special:MyLanguage/Help:DiscussionTools|DiscussionTools]] will be updated.  The page title will look different.  A page title of <code>Talk:Example</code> will look like <code>Talk: Example</code> instead.  [[mw:Talk:Talk_pages_project/Usability|Tell the Editing team]] if your wiki would like [[w:en:French spacing|French spacing]] or other language-specific changes.  You can see [[mw:Special:MyLanguage/Talk pages project/Usability/Prototype|some of the proposed changes]].

Links to this task plus https://www.mediawiki.org/wiki/Talk_pages_project/Usability#Phase_3:_Framing_context would be appropriate. If this is too long, then the last sentence can be removed.

@Whatamidoing-WMF The DiscussionTools changes are another thing, but I'm wondering if we should also separately announce that thanks to the new markup, you can separately style the namespace/separator/title in the page heading.

Have we written any documentation on how to style the namespace/separator/title in the page heading yet?

This patch caused the failure of one of the unit tests in mobileapps microservice, see https://phabricator.wikimedia.org/T316115 for more details.

Have we written any documentation on how to style the namespace/separator/title in the page heading yet?

Yes, I documented the markup in this task's description, which would be enough for people to figure it out.

So the Tech/News notice for the markup needs to say something like:

You can use CSS to change the style of <h1> headings.  The <h1> headings show the page title at the top of the page (e.g., <code>Talk:Example</code>).  For example, you can change the CSS class="mw-page-title-separator" to add spaces (e.g., <code>Talk : Example</code>).  [https://phabricator.wikimedia.org/T306440]

However, I assume from T306440#8167858 that this is not quite ready to be announced yet? (Peter estimated that the other announcement, in T306440#8167858, should be held until early September.)

For Tech News - I think we'd only include specific technical details about how to use these new CSS classes if we expect and hope that editors and/or communities widely start to use them (via local overrides/customizations). However, I'm not sure if this is true?
I.e. I was under the impression that these classes are intended to be used by extensions/core to change the default, and thus any documentation&announcement would mainly be intended to help editors/communities to either replace the previous (plain) default, or to further customize the new/future defaults.
If the above is accurate, then I think it would make more sense to have a Tech News announcement once the new defaults are ready to go out (and per T306440#8163297 - once the implementation is stable).

For Tech News - I think we'd only include specific technical details about how to use these new CSS classes if we expect and hope that editors and/or communities widely start to use them (via local overrides/customizations). However, I'm not sure if this is true?
I.e. I was under the impression that these classes are intended to be used by extensions/core to change the default, and thus any documentation&announcement would mainly be intended to help editors/communities to either replace the previous (plain) default, or to further customize the new/future defaults.
If the above is accurate, then I think it would make more sense to have a Tech News announcement once the new defaults are ready to go out (and per T306440#8163297 - once the implementation is stable).

This is accurate - we hope to provide the correct : character and spacing in core. Hopefully on-wiki customisation of these classes will be minimal, and needn't be encouraged.

As I expect French-language projects to be particularly interested in this, I have mentioned this at the French Wikipedia.

DECIDED

  • No announcement will be made in Tech/News about this new technical capability that this ticket introduces at this time.
  • Instead, we will announce the introduction of a space between TALK: (read: the namespace a page exists within) and PAGE_TITLE (read: the talk page's title) as part of the announcement we will do to accompany T304372

Test wiki on Patch demo by JKlein (WMF) using patch(es) linked to this task was deleted:

https://patchdemo.wmflabs.org/wikis/65d33f5a9f/w/