Page MenuHomePhabricator

Investigation: How to best support custom footnote marker groups in VE, Parsoid, and read mode?
Closed, ResolvedPublic

Description

Footnote markers are currently customized using divergent methods, listed below. The focus of this task is to explore and plan a consolidation of these methods.

Custom group names
Cite comes with no predefined custom groups, these must be defined by each wiki.

See https://www.mediawiki.org/wiki/Help:Cite#Grouped_references to read about the group mechanism in general.

See https://en.wikipedia.org/wiki/Help:Cite_link_labels to see how the mechanism is used on English Wikipedia.

Custom groups are usually implemented using both of the low-level approaches below. Wikitext usage is supposed to be agnostic of which approach will be used during rendering.

Legacy parser: i18n messages with a symbol alphabet
An i18n message is created for each group, using the form MediaWiki-Cite link label group-<group name>. The message contains a sequence of all symbols that will appear, for example en:MediaWiki:Cite link label group-lower-greek which proceeds like "α β γ δ…"

Use PrefixIndex to see all the customized lists for a wiki, https://en.wikipedia.org/w/index.php?title=Special:PrefixIndex/MediaWiki:cite_link_label_group-
Or use global search to list all custom groups

Parsoid: CSS counter
counter is only applied to inline footnote markers.

The counter style is built into Cite and is customized for each language using a CSS variable:

.mw-ref > a[ style~='mw-Ref' ]::after {
	content: '[' counter( mw-Ref, var( --cite-counter-style ) ) ']';
}

Custom groups are implemented using a CSS rule selecting on an RDFa attribute set to the group name, for example

.mw-ref > a[style~="mw-Ref"][data-mw-group=lower-greek]::after {
	content: '[' counter( mw-Ref, lower-greek ) ']';
}

CSS symbols can be provided to hardcode digits not commonly supported by browsers, for example this rule built into Cite:

@counter-style lzh-counter {
	system: numeric;
	symbols: '〇' '一' '二' '三' '四' '五' '六' '七' '八' '九';
}

Parsoid: CSS list-style-type
Example:

.reflist-persian-alpha ol:lang( fa ) li {
	list-style-type: persian-alpha !important;
}

This method only supports the list styles provided by each browser, which varies. list-style-type is only applied to references lists.

Survey of existing custom groups
Almost all of the groups are used to switch between different alphabets or numerals, with very few groups attempting any deeper customization. When the symbol sequence runs out, almost all groups extend it using a pattern like "aa ab ac ad".

Alphabets are used in lower- and uppercase variants. Roman numbers as well. Greek letters are only ever lowercase.

Not all wikis are using their local alphabet, so upgrading the software to use localized alphabets will involve communication.

Some wikis use English group names identical or similar to the examples given in documentation or CSS list-style-type names (eg. "lower-greek"), some other wikis use localized group names for the predefined groups (eg. "kleine-letter-Grieks")

The sole group to follow a different pattern is https://hy.wikipedia.org/wiki/MediaWiki:Cite_link_label_group-N which should be investigated a bit more. Here's an example usage: https://hy.wikipedia.org/wiki/O_Tannenbaum

Recommendation

After reviewing all custom groups, the range of what is being achieved is extremely narrow, and it seems best to replace with a programmatic solution that generates the alphabet following a set pattern.

This seems like a perfect fit for Community Configuration. We want the customized groups to be discoverable and easy to maintain. I imagine an interface in which an admin can add multiple groups each having a free-form name, and a symbol alphabet chosen from a dropdown list of preset alphabets with built-in support, numbering roughly 30.

Resulting configuration for a given wiki on the backend would look something like this, showing that the site default to decimal numbers but includes several alternative symbol sequences:

{
  "default": "decimal",
  "persian-alpha": "farsi",
  "kleine-letter-Grieks": "lower-greek",
  "lower-roman": "lower-roman",
}

Event Timeline

(moved to task description)

awight moved this task from Sprint Backlog to Demo on the WMDE-TechWish-Sprint-2024-10-16 board.

Ready to discuss, please see the "Recommendation" section in the task description.