Page MenuHomePhabricator

ToC has difficulty rendering section headings that contain the date template
Open, MediumPublic

Description

The Vector 2022 ToC appears to render section headings that include the date template ({{date}}) in an unexpected way:

image.png (678×1 px, 168 KB)

Behavior

  1. Visit a page – regardless of the namespace – where the Vector 2022 ToC is available. E.g. https://www.mediawiki.org/wiki/Talk_pages_project/Replying .
  2. Scroll the ToC such that a section that includes the {{date}} template in the page's source text is in view . E.g. https://www.mediawiki.org/wiki/Talk_pages_project/Replying#5_October_2022(2022-10-05).

❗️ Actual

  1. The H3 section heading titled "5 October 2022" appears within the ToC as "5 October 2022(20222-10-17)"

✅ Expected

  1. The H3 section heading titled "5 October 2022" appears within the ToC as "5 October 2022"

Event Timeline

We're discussing this on Slack and we wonder whether this might be better addressed on wikis via a <time> tag but it requires us getting a better understanding of what it's purpose is.

While this task probably should be sorted somehow (I'll look into what is actually displaying double dates), the template shouldn't be used in the wild (on en.wp at least, you're inconsistently pointing to MediaWiki wiki as a testbed and en.wp as the source of the template).

While this task probably should be sorted somehow (I'll look into what is actually displaying double dates), the template shouldn't be used in the wild (on en.wp at least, you're inconsistently pointing to MediaWiki wiki as a testbed and en.wp as the source of the template).

Yes, these templates are two different templates, so this isn't actually going to be reproducible on en.wp with this template directly. You might be able to manage it with an arbitrary minimal sandbox template.

Regarding this template, line 68 of the MW wiki template is

{{#if:{{{1|}}}|
<span style="display:none">(<span class="dtstart">{{padleft:{{{1}}}|4|0}}{{#if: {{{2|}}}|-{{padleft:{{{2}}}|2|0}}}}{{#if: {{{3|}}}|-{{padleft:{{{3}}}|2|0}}}}</span>)</span>
}}

The parser should probably support this kind of HTML/wikitext in the TOC, as it does wikitext today, regardless of any local improvements possible for this template. The pattern of display: none content extends elsewhere, though I'm not sure I'd call it common off the cuff.

dtstart is a microformat, which is likely what is motivating this display none version. I do not know how or whether microformats play with <time> nicely.

As for the reason why there's a microformat, this existed in the original version of the template with no obvious motivation. Checking English, the English version had its own microformat introduced in November 2008 from no.wiki (there's a bad history merge in English's version but I don't think it impacts this discussion), which was included in its originating version without obvious motivation in March 2008. Neither the en.wp nor no.wp templates carry the microformat anymore.