Page MenuHomePhabricator

Parsoid title first char is upper case, while legacy HTML title first char is lower case
Closed, ResolvedPublic

Description

Parsoid title first char is upper case, while legacy HTML title first char is lower case

Example:
https://ja.wikipedia.org/wiki/Momograci

Screenshot:

title_uppercase.png (156×1 px, 121 KB)

Event Timeline

This is the "displaytitle" feature. This is actually working as-designed: the <title> element in the document is the "database name" of the article, which might not match the title displayed in the <h2> (or in the <title> of the eventual article page) which can be customized. Other examples are https://en.wikipedia.org/w/index.php?title=H2O&redirect=no where the 2 is subscripted in the <h2>.

See T324431: Parsoid: displaytitle HTML now appearing in <title> element rather than page title where a regression in this behavior was fixed.

This is probably a documentation gap, but it is working as designed.

At the moment we're treating this as a documentation gap: https://m.mediawiki.org/wiki/Specs/HTML/2.8.0 in general doesn't have much documentation on the contents of the document <head>, and that extends to <title> as well.

There *is* a *tiny* bit of documentation about DISPLAYTITLE buried in the "Changes since Spec/HTML/2.7.0" which is basically just a reference to T294621. The best description of the current situation is in the commit message of this patch.

The tl;dr is that Parsoid output reflects the editor's input to the displaytitle algorithm, as expressed in wikitext, and is what's used by VisualEditor for editing the wikitext. But the actual displaytitle shown on the page is the result of further algorithmic processing, including deduplication of wikitext directives, -{T|...}- language conversion blocks, the noreplace argument to the displaytitle parser function, and the $wgRestrictDisplayTitle configuration flag. I believe that ParserOutput::getDisplayTitle() contains a reliable display title (although there are additional games played with the namespace prefix of the display title in OutputPage::getUnprefixedDisplayTitle() and technically extensions could contain direct calls to OutputPage::setDisplayTitle() as well) but that is not currently reflected in the Parsoid document. I'm going to leave this task open for documentation of the current behavior of <title> and {{DISPLAYTITLE}}; please open a new task to request that Parsoid emit the actual processed DisplayTitle (eg, somewhere in <head>) as a feature request if that is needed.

(Also worth noting that Parsoid is likely to embed the metadata contents of ParserOutput inside private data-parsoid attributes in the near future as part of the selective update work. Technically you could probably extract the displaytitle from there once that's done, but the contents of data-parsoid are considered parsoid-internal and will change without notice.)