Parsoid/Parser Unification/Cite CSS: Difference between revisions
Updating the timeline to the current state |
|||
| (64 intermediate revisions by 15 users not shown) | |||
| Line 1: | Line 1: | ||
<languages /> |
|||
<translate> |
|||
<!--T:71--> |
|||
This page describes features being actively worked on by the [[<tvar name=1>m:Special:MyLanguage/WMDE Technical Wishes</tvar>|Wikimedia Germany Technical Wishes team]] as part of their ongoing focus area [[<tvar name=2>m:Special:MyLanguage/WMDE Technical Wishes/Reusing references</tvar>|reusing references]]. |
|||
== Parsoid CSS for footnote numbering == <!--T:42--> |
|||
{{draft}} |
|||
</translate> |
|||
{{Tracked|T370027}} |
|||
<translate> |
|||
Like all extensions, the Cite extension has localized messages. However, a significant portion of the localized messages are for formatting and for localizing the numbering scheme. |
|||
=== Background === <!--T:43--> |
|||
</translate> |
|||
<translate><!--T:44--> Wikis that use localized numbering schemes for references (e.g. <tvar name=1><code>[۶]</code></tvar> on Persian Wikipedia) currently rely on CSS styling in <tvar name=2>{{ll|Parsoid}}</tvar> read mode and in <tvar name=3>{{ll|VisualEditor}}</tvar>.</translate> |
|||
<translate><!--T:72--> The original parser localizes the markers as plain HTML, and we will move towards rendering plain HTML from Parsoid as well.</translate> |
|||
<translate> |
|||
Parsoid takes a different approach than the legacy parser and uses CSS to perform the number-format-specific localization of the Cite extension. One of the reasons for this approach is to ensure a good editing experience in editing clients like VisualEditor: when citations are modified (added / removed), using CSS ensures that the numbers adjust automatically and consistently. Otherwise, VE (and other clients) would have to make a server request to re-render all citations each time one is added or removed which can make for a poor and inefficient experience. |
|||
=== How can I help? === <!--T:52--> |
|||
==== Current phase: on-wiki CSS cleanup for footnote markers ==== <!--T:73--> |
|||
Wikis should add appropriate CSS rules to their <code>MediaWiki:Common.css</code> file to ensure proper localization of citations in Visual Editor, given this difference in how citation number localization is performed. This will become even more important as we start to migrate toward the use of Parsoid HTML for readers, not just for editing. |
|||
</translate> |
|||
{{Tracked|T377458}} |
|||
{{Note|type=info|text={{anchor|mw-Ref removal}}'''<translate><!--T:74--> Site interface admins</translate>''' - <translate><!--T:75--> You can help by removing all "<tvar name=1>mw-Ref</tvar>" rules on your site, if possible between {{date|2025|02|20}} and {{date|2025|03|20}}, otherwise the development team will assist your wiki in making these changes.</translate><br /><translate><!--T:76--> During and after this transition there should be no difference for readers, this is purely a cleanup.</translate> |
|||
}} |
|||
<translate> |
|||
== Which wikis are impacted? == |
|||
===== Example ===== <!--T:77--> |
|||
Pretty much any wiki that uses localized numbering schemes will be impacted. |
|||
<!--T:78--> |
|||
There are two sources for localization: (1) language-specific localization messages in the Cite extension repository (2) message overrides defined in the <code>MediaWiki</code> namespace on a particular wiki. That is, for a given language <code>br</code> and message <code>cite_references_link_many_format</code> (to take a specific example) in order to determine if your language is affected, you should check to see if <code>https://<your wiki>/wiki/MediaWiki:Cite_references_link_many_format</code> has non-default content; this should include both wiki-specific overrides as well as any defaults set in <code>i18n/<language code>.json</code> in the <code>Cite</code> extension repository. |
|||
All of the examples below may be removed if they appear on your wiki. |
|||
</translate> |
|||
<syntaxhighlight lang="css"> |
|||
Specifically, any wiki using a language that provides a localized message for one of these Cite extension messages may need CSS rules for Parsoid HTML |
|||
/*.mw-ref > a::after { |
|||
* cite_reference_link |
|||
content: '[' counter( mw-Ref, decimal ) ']'; |
|||
* cite_references_link_many_format |
|||
}*/ |
|||
* cite_references_link_many_format_backlink_labels |
|||
.mw-ref > a[data-mw-group]::after { |
|||
* cite_references_link_one |
|||
content: '[' attr( data-mw-group ) ' ' counter( mw-Ref, decimal ) ']'; |
|||
* cite_references_link_many |
|||
} |
|||
* cite_references_link_many_sep |
|||
.mw-ref > a[data-mw-group=lower-alpha]::after { |
|||
* cite_references_link_many_and |
|||
content: '[' counter( mw-Ref, lower-alpha ) ']'; |
|||
* messages with "Cite_link_label_group-" prefix. |
|||
} |
|||
=== Language localization files in the Cite extension === |
|||
.mw-ref > a[data-mw-group=kurdish-alpha]::after { |
|||
The list of 28 language localizations present in the Cite extension are: <code>ar arz ban bcc bn br ce ckb cu en fr frp gag hi ko lez mk nb ru sl sr-ec sr-el th tly ttt uk ur vi</code>. |
|||
content: '[' counter( mw-Ref, kurdish-alpha ) ']'; |
|||
} |
|||
.mw-ref > a[data-mw-group=georgian]::after { |
|||
content: '[' counter( mw-Ref, custom-group-label-georgian ) ']'; |
|||
/* <translate nowrap><!--T:93--> And if a custom @counter-style exists only to support this rule, it can be removed as well.</translate> */ |
|||
} |
|||
</syntaxhighlight> |
|||
<translate> |
|||
Addressing localizations in these languages is easier to handle within the Content Transform Team. We are likely to resolve this via [[phab:T156350|T156350]] and these rules will be available for all these language wikis on all projects. |
|||
=== Project timeline === <!--T:79--> |
|||
=== Localized Cite messages on a wiki === |
|||
</translate> |
|||
Some wikis further localize citation formatting by using message overrides in the <code>MediaWiki</code> namespace on that wiki. |
|||
* {{date|2024|11|05}} {{done}} <translate><!--T:49--> The localized footnote numbers are included in Parsoid HTML, same as is done in the legacy parser.</translate> {{phabricator|T377454}} |
|||
* {{date|2025|01|20}} {{done}} <translate><!--T:50--> Override the local and global CSS styles responsible for the Parsoid footnote markers and de-facto disable them so that only the HTML is visible.</translate> {{phabricator|T382310}} |
|||
* {{date|2025|02|20}} {{done}} <translate><!--T:48--> Remove on-wiki Parsoid CSS rules to localize footnote marker numbering.</translate> {{phabricator|T377458}} |
|||
* {{date|2025|03|20}} {{done}} <translate><!--T:80--> Development team removes any remaining on-wiki "mw-Ref" rules.</translate> |
|||
* {{date|2025|03|27}} {{done}} <translate><!--T:81--> Final cleanup of Cite code to support footnote numbering CSS.</translate> {{phabricator|T386184}} |
|||
* <translate><!--T:82--> TBD: Make backlink numbering explicit.</translate> {{phabricator|T384948}} |
|||
* <translate><!--T:83--> TBD: Make reference list numbering explicit (both parsers).</translate> {{phabricator|T378570}} |
|||
<translate> |
|||
Here is the list of 128 wikis that have some site message defined for Cite. Note that just because your wiki is on this list does not mean that it needs a fix. Please see the next section to find out if your wiki is impacted. |
|||
<!--T:55--> |
|||
If you notice any undesirable changes to references, please leave a comment on the discussion page. |
|||
== Parsoid CSS elsewhere in Cite == <!--T:61--> |
|||
'''TODO: Refresh the table below.''' |
|||
{| class="wikitable" |
|||
|+ |
|||
!Project |
|||
!List of wikis |
|||
|- |
|||
|Wikipedia |
|||
|acewiki, amwiki, arbcom_enwiki, arwiki, arywiki, arzwiki, azbwiki, azwiki, be_x_oldwiki, bgwiki, bjnwiki, bnwiki, bswiki, cewiki, ckbwiki, commonswiki, cswiki, cvwiki, dawiki, dewiki, enwiki, eowiki, eswiki, euwiki, fawiki, fiwiki, frpwiki, frwiki, glwiki, guwiki, hewiki, hiwiki, hrwiki, huwiki, idwiki, ilowiki, itwiki, iuwiki, jawiki, jvwiki, kawiki, kkwiki, kowiki, kuwiki, kvwiki, ladwiki, lnwiki, metawiki, minwiki, mrwiki, mswiki, mtwiki, ndswiki, nlwiki, nowiki, nvwiki, ocwiki, pagwiki, plwiki, ptwiki, rowiki, ruwiki, scnwiki, scowiki, shwiki, skwiki, slwiki, sqwiki, srwiki, suwiki, svwiki, test2testwiki, tgwiki, tiwiki, trwiki, ukwiki, urwiki, viwiki, yiwiki, zhwiki |
|||
|- |
|||
|Wikiquote |
|||
|afwikiquote, enwikiquote, eswikiquote, glwikiquote, hewikiquote, hrwikiquote, itwikiquote, ruwikiquote, sqwikiquote, ukwikiquote, viwikiquote |
|||
|- |
|||
|Wikisource |
|||
|cswikisource, dewikisource, fiwikisource, frwikisource, glwikisource, hewikisource, hrwikisource, itwikisource, ruwikisource, vecwikisource, viwikisource, zhwikisource |
|||
|- |
|||
|Wikitionary |
|||
|bswiktionary, dewiktionary, enwiktionary, eswiktionary, frwiktionary, hrwiktionary, kuwiktionary, ocwiktionary, svwiktionary, trwiktionary, viwiktionary, zhwiktionary |
|||
|- |
|||
|Wikibooks |
|||
|enwikibooks, glwikibooks, hewikibooks, jawikibooks, nowikibooks, ruwikibooks, slwikibooks, viwikibooks |
|||
|- |
|||
|Wikinews |
|||
|ewikinews, ukwikinews |
|||
|- |
|||
|Wikivoyage |
|||
|ruwikivoyage |
|||
|- |
|||
|Affiliate wikis |
|||
|ruwikimedia, uawikimedia |
|||
|} |
|||
=== Reference list numbering === <!--T:62--> |
|||
=== Is there a way to see if my wiki is impacted? === |
|||
</translate> |
|||
Yes. If you open a page that has citations in VisualEditor, and the citations on the page render differently from outside VE, then your wiki either needs language-specific CSS rules (which we will handle via [[phab:T156350|T156350]] as above), or it needs CSS rules to be added to <code>MediaWiki:Common.css</code> which you will need to add. You can check whether your wiki has site-specific overrides in the <code>MediaWiki</code> namespace to determine if you need to add CSS rules in <code>MediaWiki:Common.css</code>. |
|||
{{Tracked|T378570}} |
|||
<translate><!--T:63--> Reference lists are still rendered using browser counter styling on the <li> tag, which is error-prone and doesn't support all languages.</translate> |
|||
== Is there any help with writing these CSS rules? == |
|||
<translate><!--T:64--> This may as well be rewritten to use explicit numbering instead.</translate> |
|||
Yes, we have some useful resources for you to write up these rules. |
|||
<translate> |
|||
You can use these as starting points to update your wiki's <code>MediaWiki:Common.css</code> . Depending on how your wiki's CSS is structured, you may not necessarily want to copy-paste these exact rules into your wiki, but those rules will hopefully make it quicker to update your wiki's CSS. |
|||
=== Backlink markers for reused refs === <!--T:65--> |
|||
</translate> |
|||
{{Tracked|T383036}} |
|||
<translate><!--T:66--> The backlink markers ("1.0, 1.1" or "a, b, c") on reused references in the reference list will also be changed but in a later phase of work.</translate> |
|||
=== Programmatically generated CSS rules === |
|||
<translate><!--T:67--> We plan to phase out numbered markers and default to alphabetic symbols localized to the wiki's content language.</translate> |
|||
We wrote a script to process all the localization messages (on wiki and in the Cite extension) and generated CSS rules for your wiki. You can '''[[gerrit:c/mediawiki/services/parsoid/+/849738/14/tools/generated.parsoid.cite.css.output.txt|find them here]]'''. For your wiki, these rules may work out of the box. |
|||
<translate><!--T:94--> These will still be customizable but through a simpler mechanism than the {{<tvar name=1>ll|Help:Cite#Set references to use ^ and letters</tvar>|system messages}}.</translate> |
|||
<translate> |
|||
=== CSS rules developed as part of our testing === |
|||
As part of visual diff testing, we have had to add a number of these CSS rules to the testing repo. You can see [https://github.com/wikimedia/integration-visualdiff/blob/master/lib/parsoid.custom_styles.yaml '''these rules here'''] . These are compatible with the generated rules above. But, these may also have some minor additional fixes that you might need for your wiki. |
|||
=== Square brackets === <!--T:68--> |
|||
== How can we verify changes? == |
|||
</translate> |
|||
As above, you can open the page in VisualEditor (after ensuring caches are purged) to see if your CSS fixes have improved the rendering of citations. |
|||
{{Tracked|T376717}} |
|||
<translate><!--T:84--> Some projects prefer to hide square brackets around the footnote markers.</translate> |
|||
<translate><!--T:85--> Currently this is done by adding custom CSS classes around brackets in the local <tvar name=1>[[MediaWiki:Cite reference link]]</tvar> message and custom rules to <tvar name=2>[[MediaWiki:Common.css]]</tvar>.</translate> |
|||
<translate><!--T:86--> This is not supported by Parsoid and VisualEditor.</translate> |
|||
<translate><!--T:87--> Now there's a mechanism available that's compatible with Parsoid and VisualEditor which makes it possible to hide square brackets just using CSS rather than by editing system messages.</translate> |
|||
== Reporting bugs == |
|||
<translate><!--T:88--> It's also working with the legacy parsing and can be used there when <tvar name=1>[[MediaWiki:Cite reference link]]</tvar> is unchanged or changes in there reverted.</translate> |
|||
You can report bugs on Phabricator - please use the Parsoid or Parsoid-Read-Views tag to report your bugs. |
|||
<translate><!--T:89--> Hiding the square brackets should now be done using the following CSS in <tvar name=1>MediaWiki:Common.css</tvar> or in [[<tvar name=2>Special:MyPage/common.css</tvar>|your user stylesheet]]:</translate> |
|||
== Asking for help == |
|||
You can reach out to the Content Transform Team by posting via the Talk page for this page. You may also be able to find us on IRC, but the talk page is probably the best place since the responses there might also help others. |
|||
<syntaxhighlight lang="css"> |
|||
.reference .cite-bracket { |
|||
font-size: 0; |
|||
} |
|||
</syntaxhighlight> |
|||
<translate><!--T:90--> Using <tvar name=1><code>font-size: 0</code></tvar> has the advantage of making the square brackets still show up when copy-pasting as unformatted text.</translate> |
|||
<translate><!--T:91--> <tvar name=1><code>display: none</code></tvar> is not recommended because this will remove the brackets from the content in most browsers, leading to confusing copy-paste such as <tvar name=2><code>2025<sup>[1]</sup></code></tvar> turning to <tvar name=3><code>20251</code></tvar>.</translate> |
|||
<translate><!--T:92--> Ideally affected projects with <tvar name=1>[https://global-search.toolforge.org/?q=.®ex=1&namespaces=8&title=Cite+reference+link customized Cite_reference_link message]</tvar> could remove this message altogether when they tweaked their CSS rules.</translate> |
|||
Latest revision as of 12:46, 5 August 2026
This page describes features being actively worked on by the Wikimedia Germany Technical Wishes team as part of their ongoing focus area reusing references.
Parsoid CSS for footnote numbering
[edit | edit source]Background
[edit | edit source]Wikis that use localized numbering schemes for references (e.g. [۶] on Persian Wikipedia) currently rely on CSS styling in Parsoid read mode and in VisualEditor.
The original parser localizes the markers as plain HTML, and we will move towards rendering plain HTML from Parsoid as well.
How can I help?
[edit | edit source]Current phase: on-wiki CSS cleanup for footnote markers
[edit | edit source]During and after this transition there should be no difference for readers, this is purely a cleanup.
Example
[edit | edit source]All of the examples below may be removed if they appear on your wiki.
/*.mw-ref > a::after {
content: '[' counter( mw-Ref, decimal ) ']';
}*/
.mw-ref > a[data-mw-group]::after {
content: '[' attr( data-mw-group ) ' ' counter( mw-Ref, decimal ) ']';
}
.mw-ref > a[data-mw-group=lower-alpha]::after {
content: '[' counter( mw-Ref, lower-alpha ) ']';
}
.mw-ref > a[data-mw-group=kurdish-alpha]::after {
content: '[' counter( mw-Ref, kurdish-alpha ) ']';
}
.mw-ref > a[data-mw-group=georgian]::after {
content: '[' counter( mw-Ref, custom-group-label-georgian ) ']';
/* And if a custom @counter-style exists only to support this rule, it can be removed as well. */
}
Project timeline
[edit | edit source]-
Done The localized footnote numbers are included in Parsoid HTML, same as is done in the legacy parser. T377454 -
Done Override the local and global CSS styles responsible for the Parsoid footnote markers and de-facto disable them so that only the HTML is visible. T382310 -
Done Remove on-wiki Parsoid CSS rules to localize footnote marker numbering. T377458 -
Done Development team removes any remaining on-wiki "mw-Ref" rules. -
Done Final cleanup of Cite code to support footnote numbering CSS. T386184 - TBD: Make backlink numbering explicit. T384948
- TBD: Make reference list numbering explicit (both parsers). T378570
If you notice any undesirable changes to references, please leave a comment on the discussion page.
Parsoid CSS elsewhere in Cite
[edit | edit source]Reference list numbering
[edit | edit source]Reference lists are still rendered using browser counter styling on the <li> tag, which is error-prone and doesn't support all languages. This may as well be rewritten to use explicit numbering instead.
Backlink markers for reused refs
[edit | edit source]The backlink markers ("1.0, 1.1" or "a, b, c") on reused references in the reference list will also be changed but in a later phase of work. We plan to phase out numbered markers and default to alphabetic symbols localized to the wiki's content language. These will still be customizable but through a simpler mechanism than the system messages.
Square brackets
[edit | edit source]Some projects prefer to hide square brackets around the footnote markers. Currently this is done by adding custom CSS classes around brackets in the local MediaWiki:Cite reference link message and custom rules to MediaWiki:Common.css. This is not supported by Parsoid and VisualEditor.
Now there's a mechanism available that's compatible with Parsoid and VisualEditor which makes it possible to hide square brackets just using CSS rather than by editing system messages. It's also working with the legacy parsing and can be used there when MediaWiki:Cite reference link is unchanged or changes in there reverted.
Hiding the square brackets should now be done using the following CSS in MediaWiki:Common.css or in your user stylesheet:
.reference .cite-bracket {
font-size: 0;
}
Using font-size: 0 has the advantage of making the square brackets still show up when copy-pasting as unformatted text.
display: none is not recommended because this will remove the brackets from the content in most browsers, leading to confusing copy-paste such as 2025[1] turning to 20251.
Ideally affected projects with customized Cite_reference_link message could remove this message altogether when they tweaked their CSS rules.