Jump to content

Parsoid/Parser Unification/Cite CSS: Difference between revisions

From mediawiki.org
Content deleted Content added
Updates
Some edits/formatting/clarification of override mechanism.
Line 4: Line 4:




Like all extensions, the Cite extension has localized messages. However, a significant part of the localized messages are for formatting and for localizing the numbering scheme.
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.


Parsoid take a different approach here and uses CSS to support formatting-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), the CSS approach ensures the numbers adjust consistently. Otherwise, VE (and other clients) will have to make a server request to rerender all citations each time one is added / removed which can make for a poor / inefficient experience.
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.


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.
Given this difference in how Parsoid handles citation formatting, as we are starting to migrate read views to be based on Parsoid HTML, wikis will have to add CSS rules to their MediaWiki:Common.css files to target citations.


== Which wikis are impacted? ==
== Which wikis are impacted? ==
Pretty much any wiki that uses localized numbering schemes will be impacted. Specifically, any wiki / language that provides a localized message for one of these Cite extension messages will need equivalent CSS rules: <code>cite_references_link_many_and, cite_references_link_many_format, cite_references_link_many_format_backlink_labels</code>. '''(TODO: Verify if this are all the ones that need updates).'''
Pretty much any wiki that uses localized numbering schemes will be impacted. Specifically, any wiki using a language that provides a localized message for one of these Cite extension messages will need equivalent CSS rules: <code>cite_references_link_many_and, cite_references_link_many_format, cite_references_link_many_format_backlink_labels</code>. '''(TODO: Verify if this are all the ones that need updates).'''


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 [[:br:MediaWiki:cite_references_link_many_format|https://<your wiki>.wikipedia.org/wiki/MediaWiki:cite_references_link_many_format]] 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.
There are two sources for localization: (1) language-specific localization messages in the Cite extension repository (2) Messages defined on a wiki.


=== Language localization files in the Cite extension ===
=== Language localization files in the Cite extension ===
The list of 28 language localizations 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>.
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>.


This scenario 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.
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.


=== Localized Cite messages on a wiki ===
=== Localized Cite messages on a wiki ===
This is wiki specific and we don't have a ready made list right now. But, for example, among others, we already know that eswiki, itwiki, knwiki, nlwiki, nowiki will need CSS rules.
Some wikis further localize citation formatting by using message overrides in the <code>MediaWiki</code> namespace on that wiki. This is wiki specific and we don't have a ready made list right now. But, for example, among others, we already know that eswiki, itwiki, knwiki, nlwiki, nowiki will need CSS rules.


=== Is there a way to see if my wiki is impacted? ===
=== Is there a way to see if my wiki is impacted? ===
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 T156350 as above), or it needs CSS rules to be added to MediaWiki:Common.css which you will need to add.
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>.

If your wiki has site messages for one of the message keys above, then you will definitely need CSS rules in MediaWiki:Common.css.


== Examples of CSS rules ==
== Examples of CSS rules ==
As part of visual diff testing, we have had to add a number of these CSS rules to the testing repo. You can use [https://github.com/wikimedia/integration-visualdiff/blob/master/lib/parsoid.custom_styles.yaml these rules] as starting points to update your wiki's Common.css. Depending on 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.
As part of visual diff testing, we have had to add a number of these CSS rules to the testing repo. You can use [https://github.com/wikimedia/integration-visualdiff/blob/master/lib/parsoid.custom_styles.yaml these rules] as starting points to update your wiki's <code>MediaWiki:Common.css</code>. Depending on 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.


== How can we verify changes? ==
== How can we verify changes? ==

Revision as of 20:21, 19 October 2022


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.

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.

Wikis should add appropriate CSS rules to their MediaWiki:Common.css 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.

Which wikis are impacted?

Pretty much any wiki that uses localized numbering schemes will be impacted. Specifically, any wiki using a language that provides a localized message for one of these Cite extension messages will need equivalent CSS rules: cite_references_link_many_and, cite_references_link_many_format, cite_references_link_many_format_backlink_labels. (TODO: Verify if this are all the ones that need updates).

There are two sources for localization: (1) language-specific localization messages in the Cite extension repository (2) message overrides defined in the MediaWiki namespace on a particular wiki. That is, for a given language br and message cite_references_link_many_format (to take a specific example) in order to determine if your language is affected you should check to see if https://<your wiki>.wikipedia.org/wiki/MediaWiki:cite_references_link_many_format has non-default content; this should include both wiki-specific overrides as well as any defaults set in i18n/<language code>.json in the Cite extension repository.

Language localization files in the Cite extension

The list of 28 language localizations present in the Cite extension are: 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.

Addressing localizations in these languages is easier to handle within the Content Transform Team. We are likely to resolve this via T156350 and these rules will be available for all these language wikis on all projects.

Localized Cite messages on a wiki

Some wikis further localize citation formatting by using message overrides in the MediaWiki namespace on that wiki. This is wiki specific and we don't have a ready made list right now. But, for example, among others, we already know that eswiki, itwiki, knwiki, nlwiki, nowiki will need CSS rules.

Is there a way to see if my wiki is impacted?

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 T156350 as above), or it needs CSS rules to be added to MediaWiki:Common.css which you will need to add. You can check whether your wiki has site-specific overrides in the MediaWiki namespace to determine if you need to add CSS rules in MediaWiki:Common.css.

Examples of CSS rules

As part of visual diff testing, we have had to add a number of these CSS rules to the testing repo. You can use these rules as starting points to update your wiki's MediaWiki:Common.css. Depending on 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.

How can we verify changes?

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.

Who can be reach out for help / reporting bugs

You can report bugs on Phabricator as always (TODO: Be more specific). You can also reach out to the Content Transform Team either on IRC, email, or on wiki here by posting on this talk page. (TODO: Maybe provide a single place for this?)