Description
Details
| Status | Subtype | Assigned | Task | ||
|---|---|---|---|---|---|
| Open | None | T378089 [EPIC] Wikivoyages rollout followup work | |||
| Open | None | T391624 Parsoid section edit link issues | |||
| Resolved | ABreault-WMF | T368722 Empty headings are missing edit-source button in parsoid read views |
Event Timeline
Change #1051863 had a related patch set uploaded (by Arlolra; author: Arlolra):
[mediawiki/services/parsoid@master] Add a test for empty headings
Effectively, an isolated test is,
=== ===
The legacy parser will set an empty anchor for that and Parsoid will too but, since the empty string isn't a valid id, Parsoid will generate a new id to attach data attributes to it when it's creating the pagebundle,
https://github.com/wikimedia/mediawiki-services-parsoid/blob/master/src/Utils/DOMDataUtils.php#L469-L472
which means it'll be lost when we try to find heading for the section, $dom->getElementById( $section->anchor ), based on the section metadata,
https://github.com/wikimedia/mediawiki/blob/master/includes/OutputTransform/Stages/HandleParsoidSectionLinks.php#L77-L84
Even if it was left as the empty string, getElementById probably wouldn't find it.
This is an edge case, section editing empty headings. Certainly this edit probably didn't mean to generate an empty heading,
https://en.wikivoyage.org/w/index.php?title=M%C3%A4ntt%C3%A4-Vilppula&diff=4897416&oldid=4897358
I made this edit and the parsers agree now,
https://en.wikivoyage.org/w/index.php?title=M%C3%A4ntt%C3%A4-Vilppula&diff=4902368&oldid=4897418
Could we change both Parsoid and the legacy parser to agree that === === is not a valid heading? That would avoid the whole "blank ID" issue.
Some of this stuff looks less convincing,
https://en.wikipedia.org/w/index.php?title=Sarajevo_International_School&diff=1053743782&oldid=1053741050
https://en.wikipedia.org/w/index.php?title=Generation_Italy&diff=1049016314&oldid=954035270
but I could see wanting to edit a section of the page without naming it, as a feature,
https://en.wikipedia.org/wiki/1983_Fenland_District_Council_election
It's not just that literal case though, it's any effectively empty heading. The anchor text is the normalized text content of the heading. Grepping for all that might be challenging.
For example, === _ === is also empty because of Sanitizer::normalizeSectionNameWhiteSpace
We could choose "_" as the id for an empty heading and probably at least wouldn't have any collisions.
Blank headings have another visible negative output: the table of contents displays... lots of whitespace. If this were to be supported, I think that output needs to be fixed regardless. From my point of view, I think that's probably sufficient cause not to support this kind of wikitext.
The pattern of empty headings just to have edit buttons is probably not a common one either, due to someone noticing that issue.
Here's a search on English Wikipedia that has mostly false positives. (It excludes user namespace and talk namespaces, for clarity, as well as non-wikitext content model.) I fixed one and see just a couple others from a glance, so I think the pattern isn't high value. But other wikis may be doing something different. Tried to global search but got a timeout (which was not unexpected).
Emitting a lint error would be about the most you should have to do for wikis to adjust behavior, and that's me being conservative.
Change #1113209 had a related patch set uploaded (by Arlolra; author: Arlolra):
[mediawiki/core@master] Suppress error log for empty headings
From the commit message of T368722#10481825
Parsoid could eagerly assign a generated id when it runs into this
situation but that wouldn't match the legacy parser.T368722 suggests either considering empty headings as invalid and
rendering the markup syntax or emitting a lint to have the uses cleaned
up.
I guess we need to pick one and T368722#10008311 seems to suggest an new empty-heading lint.
Change #1113209 merged by jenkins-bot:
[mediawiki/core@master] Suppress error log for empty headings
Also found a few of these on lmowiktionary, for instance https://lmo.wiktionary.org/wiki/bronc%C3%A0
Change #1135525 had a related patch set uploaded (by Arlolra; author: Arlolra):
[mediawiki/extensions/Linter@master] Add a new lint category for empty headings
Change #1135528 had a related patch set uploaded (by Arlolra; author: Arlolra):
[mediawiki/core@master] Add i18n for empty heading lint category
Thank you for asking about this at en.WP. A brief discussion, linked from a couple relevant notice boards, has not surfaced any potential negatives regarding this new Linter "category".
The discussion recommends replacing the missing section header with "Untitled" unless there is a better, more appropriate option.
It looks like this should go ahead. As part of deployment, please go through your developers' checklist for adding a new Linter "category", including documenting the new "category" on the MediaWiki site and linking to it from the relevant MediaWiki pages.
It looks like this should go ahead. As part of deployment, please go through your developers' checklist for adding a new Linter "category", including documenting the new "category" on the MediaWiki site and linking to it from the relevant MediaWiki pages.
The checklist is at https://www.mediawiki.org/wiki/Parsoid/Adding_a_new_lint_category if you want to review it
The discussion recommends replacing the missing section header with "Untitled" unless there is a better, more appropriate option.
I created https://www.mediawiki.org/wiki/Help:Lint_errors/empty-heading with that recommendation
Change #1135525 merged by jenkins-bot:
[mediawiki/extensions/Linter@master] Add a new lint category for empty headings
Change #1135528 merged by jenkins-bot:
[mediawiki/core@master] Add i18n for empty heading lint category
Two new linter categories have been added so I think it could be included in the Tech News
For Tech News (thanks for the suggested entry!) please could someone suggest (or improve my) draft wording, and confirm the best timing? I imagine it would be something like:
- A new lint-error category has been created: [[Special:LintErrors/empty-heading | {{int:linter-category-empty-heading}} ]]. The Linter extension's purpose is to identify wikitext patterns that must or can be fixed in pages and provide some guidance about what the problems are with those patterns and how to fix them.
Question 1: What is the second new linter? [Thanks, Nemoralis!]
Question 2: I believe these will all be getting deployed with the 'train' this week, and thus will be linkable (blue-links) at all Wikimedia-wikis the following week, and have content very-soon after, and hence this proposed entry would be suitable for next week's edition (delivered April 21). --- If that is wrong, and you'd prefer it a week later (e.g. to give time for categories to automatically populate if that isn't instant? or UI-translations?), please correct me with the preferred announcement date.
I meant one category, sorry about that. It seems that when I translated Linter's strings on translatewiki, I thought one of them was a new category too.
If that is wrong, and you'd prefer it a week later (e.g. to give time for categories to automatically populate if that isn't instant? or UI-translations?), please correct me with the preferred announcement date.
Announcing next week sounds good, I've added it
https://meta.wikimedia.org/w/index.php?title=Tech%2FNews%2F2025%2F17&diff=28548044&oldid=28528314
Change #1051863 merged by jenkins-bot:
[mediawiki/services/parsoid@master] Lint empty headings
Empty headings is currently used in Chinese Wikipedia DYKN page: https://zh.wikipedia.org/wiki/Wikipedia:%E6%96%B0%E6%9D%A1%E7%9B%AE%E6%8E%A8%E8%8D%90/%E5%80%99%E9%80%89
Change #1139521 had a related patch set uploaded (by C. Scott Ananian; author: C. Scott Ananian):
[mediawiki/vendor@master] Bump wikimedia/parsoid to 0.21.0-a27
Change #1139521 merged by jenkins-bot:
[mediawiki/vendor@master] Bump wikimedia/parsoid to 0.21.0-a27

