(originally reported at T13555#9407882 and discussed at https://de.wikipedia.org/wiki/Wikipedia:Technik/Skin/MediaWiki/Änderungen#Geänderte_Überschriftenstruktur)
Context
DiscussionTools adds wrapper elements that look like <div class="mw-heading"> to wikitext headings. Specifically, the following wikitext:
<h2>Hello</h2>
…which would ordinarily turn into the following HTML:
<h2><span class="mw-headline" id="Hello">Hello</span></h2>
…turns into the following instead:
<div class="mw-heading mw-heading2 ext-discussiontools-init-section"><h2><span class="mw-headline" id="Hello" data-mw-thread-id="h-Hello"><span data-mw-comment-start="" id="h-Hello"></span>Hello<span data-mw-comment-end="h-Hello"></span></span></h2></div>
This happens on all talk pages and pages in $wgExtraSignatureNamespaces, which includes Wikipedia: and Help: on most Wikimedia wikis, even if those pages do not contain discussions and don't look any different.
Problem
We added those wrappers a year ago in T314714, and for the most part they did not cause problems (although there were some: T331474), but last week, after we added some forward-compatibility styles for T13555, more problems appeared. The new styles cause the <h2> to become an inline element, and change the value against which relative font sizes are computed, which means that many styles (and TemplateStyles) applied to it no longer have the desired effect.
For example, given the following wikitext:
<h2 style="border: 1px solid green; background: lightgreen; padding: 5px; font-size: 1.5em;">Hello!</h2>
…these pages demonstrate the problem:
- https://test.wikipedia.org/wiki/Heading_with_styles
- https://test.wikipedia.org/wiki/Wikipedia:Heading_with_styles
While it is possible to update the styles, it is tricky (since you can't add classes or styles on the wrapper, and since you need to style the headings differently depending on whether the wrapper is present). In practice the easiest solution in wikitext is just not using headings, which is bad for accessibility. Other solutions may require adding extra wrappers outside the heading, which would interfere with the mobile site and Parsoid's section wrapping.
We were planning to use the same HTML structure for headings on all pages in T13555 (not just in DiscussionTools), and this problem would affect that as well.
Solution?
I think there's a chance we could resolve all of these issues by moving the style and class attributes (or maybe all attributes) defined on the <h2> in the input wikitext to the wrapper <div class="mw-heading"> in the output HTML. That would restore the previous structure (although with different tags), and it seems to fix the problems on the pages where I tried it. There might be some cases where it wouldn't help, though, and it might be confusing to the editors writing the wikitext. And there might be problems with that that I didn't think of yet.
Solution?
If we could distinguish whether the heading was originally written using == or <h2> in wikitext, we could use that information to decide not to add wrappers (and discussion metadata) to the <h2> headings. It's probably very rare for them to be used in discussions.







