Page MenuHomePhabricator

Investigation: survey affordances of the {{reflist}} template on wikis where it's preferred over the <references> tag
Closed, ResolvedPublic

Description

Look through the dominant {{reflist}} templates (name may vary) and reverse-engineer all functionality from the template documentation, template source, and any transcluded stylesheets.

  • Choose wikis to study

Functionality which is passed through the template to <references> will be omitted here when we already have parity. Examples:

  • refs for list-defined references
  • group. Note that some templates decouple predefined list marker styles from the "group".
  • responsive. Most multicolumn implementations in reflist templates are now a facade in front of Cite responsive="1" plus minor CSS styling, but there are also some extra subfeatures which should be backported into Cite.
  • Stylesheets like on enwiki are equivalent to global style overrides and were only attached to the template for encapsulation.
  • Parameter validation.

Multicolumn is not omitted from the survey, but note that the Cite responsive feature already provides baseline parity.

  • Migration was started in 2015, see T33597: Render references list in multiple columns based on the number of items.
  • Note that the configuration variable $wgCiteResponsiveReferences sets the default value, it's not a feature flag. The feature is available on all sites.
  • This could be ported to community configuration, which might also encourage more sites to enable it as default.
  • Interesting that the default threshold of 10 is never overridden. This could be made into community configuration, but might not be appropriate to override on individual reflists?

Wikis reviewed

  • enwiki
    • {{reflist}}
    • multicolumn
      • TBD: columns are broken in template docs?
    • predefined templates like {{notelist}} come with a default group name, which set the alphabet for its footnotes and are each paired with a specific {{efn}} variant.
    • Possible misfeature: can override the footnote markers separately in reflist vs. article. "This should be used with care as it can be confusing to readers."
    • Can ignore the unbalanced {{refbegin}} and {{refend}} wrap bibliographic-style citations, but never a reflist.
  • frwiki
    • {{références}}
    • multicolumn
      • Automatically change number of columns depending on namespace.
      • Some templates add a tracking category when number of columns > 2
    • Adds an element for CSS, div.reference-cadre
    • TBD: what is tabindex="0" doing, it seems like a no-op?
    • {{références nombreuses}} collapses using a scrolling frame. This is pure CSS, using height and overflow: auto.
  • eswiki
    • {{listaref}}
    • multicolumn
    • set symbols separately from group name
  • arwiki
    • Sometimes an explicit reflist div is included in wikitext, eg in this section.
    • Uses unbalanced templates like {{بداية المراجع}} to open a div tag.
    • Often doesn't use <references> at all!
    • Multicolumn
    • Hanging indent styling.
    • Collapse to a scrolling box (pure CSS).
    • {{مراجع}}
    • Optionally switch containing element to dir=ltr
    • Set symbol separate from group name
  • svwiki
    • Decided not to use the template in 2007. See discussion.
  • itwiki
    • Decided not to use the template in 2017. See discussion.
  • plwiki

Summary of features

All existing functionality we've found in the wikis above can be reduced to these categories:

  • CSS tweak. These may be applied globally to all reference lists, selected by choice of template, or configured by template parameter.
  • Translation. Wikitext tag names are not currently localized, but template and parameter names can be.

Less commonly, the template extends beyond the reference list to its container: setting the section title and style, and suppressing the edit links. This is out of scope for our project. See T265753: The automatic <references/> list (when absent) should include an automatic heading above it for more discussion.

A full list of features, [TBD: and links to follow-up investigation]

  • Multicolumn. Already have sufficient support in Cite responsive.
  • RTL / LTR. More investigation needed, it's possible that Cite dir is already sufficient.
  • Predefined configurations using a short name, eg. "{{references-scroll}}".
  • Translated names, eg. "{{références}}".
  • Footnote mark symbol, eg. "β". This is already implemented, but needs redesign to rationalize and consolidate.
  • Collapsed list, scrolling in a fixed-height frame.
  • Miscellaneous styling maybe not shared across many wikis.

Suggested reimplementations

Free styling

Pass through the class and style parameters. This is already an accepted pattern in wikitext, and a standard building block in HTML and component frameworks (eg vuejs).

Passing through data-* attributes as well would allow more sophisticated customization, which is still compatible with CSS selectors but allows for arbitrary extra information to be attached rather than just a yes/no class name boolean. For example, data-columns=2.

A suite of standardized reflist style tweaks can be bundled with Cite, for example "collapsed", "two-column", "greek". These can be applied one at a time or in combination.

Visual editor could expose these as checkboxes each toggling a class name, and a free text "class" attribute for additional user- or site-provided styles.

Community configuration could also expose these styles as checkboxes, but as a default to apply to all reflists. "no-" reverse styles should be provided to counteract these, eg. "no-collapsed".

Sites can override the bundled styles by adding more CSS rules for the class.

Free styling can be used to support the following features

  • Multicolumn fine-tuning. The most common subfeature seems to be a parameter for column width. There should be some design work done to evaluate the tradeoffs for various screen and font sizes, vs. giving authors flexible layout options.
  • Collapse to a scrolling box, with height and overflow. Some wikis such as enwiki have written policies discouraging collapsing because of accessibility issues. Any implementation of collapsing needs to solve these issues. Individual users can opt-in to collapsing styles in their personal overrides, of course.
  • Arbitrary one-off, site-customized, styles.
  • Forwards compatibility. Any template that passes through style and class attributes can be used in combination with existing or future styles. (To compare with a feature not compatible with generic styling: the responsive attribute requires explicit wiring between the template's multicolumn parameter and the responsive parameter.)

Tech breadcrumb: attributes can be wired in PHP using Sanitizer::fixTagAttributes, which converts an arbitrary string of user-provided attributes into a sanitized subset safe to reapply to the output.

See also, some unresolved discussion in T37704: Drop support in wikitext for inline styles about concerns with passing through styles.

Right-to-left

TBD: Work should continue independently, probably by improving the existing dir attribute.

Translation

Visual editor already works around this entire problem by hiding literal tag names from the user.

The translation problem is the same for all wikitext tags, and underlies much gratuitous template usage. T30980: parser tags such as <ref>, <poem>, <timeline> etc. cannot be localized

Predefined names—and the inevitability of templates

It seems likely that communities will still want to hold on to their templates, because of translation and to use predefined names for a set of styles, eg. "footnotes". Here I'll propose a minor tweak to TempateData which could help in that scenario:

Several new TemplateData parameter data types might come to the rescue here:

  • "ref list" - Giving a parameter this type gives the visual editor a hint that it holds a collection <ref> tags which could be inspected and manipulated.
  • "class" - ChipInput for boolean class names. If we find a reference list when introspecting the template output, we could even provide the reflist class presets...
  • "style" - inline CSS, with validation that you're not using illegal rules or bad syntax.

Footnote symbols

The group name, choice of symbol alphabet, and whether or not to show the group name should be split into separate features. But they are intertwined so first we should better understand user needs.

There are divergent implementations of footnote symbols which need to be merged, in conjunction with T370027: [Epic] Parsoid CSS counter reset footnote/backlink mechanism should be dropped in favor of plain text:

  • Literal symbol dynamically produced by Cite, for example "1", "2".
  • MediaWiki messages with the entire sequence of symbols, for example lower-alpha.
  • CSS list-style and counter-reset.

Community configuration should be provided to set the default and other predefined symbol sequences.

Visual editor could allow symbol customization for each reference list.

Make it impossible for the reflist marker style to be different than the footnote markers in the article. This probably means we should discourage any usage of CSS list-style, and always generate the markers explicitly in MediaWiki.

Suggested migration

Existing templates could be simplified incrementally, by pushing customizations into CSS and applying to all reflists or depending on a class name.

The shared, generalized styles should be provided through the Cite extension, before we ask communities to adapt. Ideally, the bundled styles can be used as-is, or if they are customized then this is done on top of a small set of known classes which simplifies future migrations.

Follow up

If necessary we can run the scraper to analyze usage frequency of specific features.

Follow up by roughly estimating the effort to reimplement each behavior in Cite for the <references> tag.

Event Timeline

awight renamed this task from Investigation: catalog affordances of the {{reflist}} template on wikis where it's preferred over the <references> tag to Investigation: survey affordances of the {{reflist}} template on wikis where it's preferred over the <references> tag.Oct 11 2024, 10:19 PM
awight updated the task description. (Show Details)

This task or the outputs of it could/should be a child of T95543: Obviate the need for wikis' wrapper and functionality-replacement templates.

Global search query to find reflist template: TBD (copy snippet from other tasks)

Wikidata is always a good starting point!

Stylesheets like on enwiki are equivalent to global style overrides and were only attached to the template for encapsulation.

Encapsulation is doing a lot of work there for what TemplateStyles provides. :)

enwiki

  • TBD: columns are broken in template docs?

Not that I'm aware of.

image.png (369×968 px, 30 KB)

(I had to zoom out.) CSS columns can interact weirdly when inside a <table> with auto width, but this table is 100%. CSS columns automatically reduce when defined solely in terms of their column width, or when defined in terms of both column width and count, with an absolute minimum of one column regardless of the width set. (But not when defined solely by count - you will always get that number of columns when only count is set.)

|colwidth=

It is common to see widths defined that differ from the default, especially with shortened footnotes ({{sfn}}). (And unfortunately in many cases the same as the default 🙄.)

It should be noted that <references responsive> does not in fact provide parity, but a reasonable 80% of parity. references responsive only triggers at 10 or more references as you've identified with the configuration option, while colwidth is applicable at all counts of references. It also applies to a different element presently, which may have some impact on the sizing of the columns (see my wariness with adjusting font sizes).

Interesting that the default threshold of 10 is never overridden.

People don't know it can be? I have no idea. :) 10 is probably just a good number for most of our uses, but it's pretty arbitrary and non-WMF wikis or even non-WP wikis might want alternatives. You probably wouldn't want to allow it to be set to too small or too large a number as defeating the purpose...

(I'm not even sure every wiki has references responsive as the default, work stalled on deploying it to the fleet.)

  • Possible misfeature: can override the footnote markers separately in reflist vs. article. "This should be used with care as it can be confusing to readers."

There is I think at least one task lying around how the footnote marker in the article can differ (1 rather than alpha) from the footnote in the references list. It is seen to be a bug.

  • Can ignore the unbalanced {{refbegin}} and {{refend}} wrap bibliographic-style citations, but never a reflist.

Refbegin/refend are indeed irrelevant to the mission of understanding <references/> uses. And are a target for replacement with extended references anyway in the vast majority of cases.

Collapsed list, scrolling in a fixed-height frame.

This is something of a misfeature along the lines of accessibility (internal scroll bars are a confusion point for users who get 'stuck' inside them, and there is a set of people who no longer have the dexterity to grab the scrollbar) and other wikis probably shouldn't have it. English Wikipedia currently puts it in the "don't do that" pile.

Pass through the class and style parameters.

I would rather steer away from no-holds barred style. Pick out the primary styles and add parameters to allow customization of those specific styles. (This is an opinion I've definitely finished coming to after having to deal with dark mode and with the now-incumbency of mobile resolutions - too many templates provide too much customization for no good reason and hacking around them with !important colors and widths is no fun.)

No particular issue with allowing class to pass through. data- might also be nice.

"ref list"/"class" - ChipInput for boolean class names/"style"

All of these sound like good ideas. I'm not sure what would be used to validate style. Just the core Sanitizer.php? See also T37704 I guess. And I know there has been reticence by several in the VE crew about supporting inline styling.

I'm not sure I get what you're thinking about here for class though, even after coming to know what a ChipInput is.

Less commonly, the template extends beyond the reference list to its container: setting the section title and style, and suppressing the edit links. This will be left out of scope for now.

This is a discussion point in T364830, but probably deserves its own task. I'm not personally a fan of it in the slightest. There is also T265753 on a similar dimension.

Thank you @Izno for the detailed and thoughtful feedback! I'll try to act on all of the points you made, mostly by integrating into the task description. My responses below are limited to points I still have questions about.

Pass through the class and style parameters.

I would rather steer away from no-holds barred style. Pick out the primary styles and add parameters to allow customization of those specific styles. (This is an opinion I've definitely finished coming to after having to deal with dark mode and with the now-incumbency of mobile resolutions - too many templates provide too much customization for no good reason and hacking around them with !important colors and widths is no fun.)

We have a developer on the team who completely agrees, and personally I fall somewhere in-between. My thinking is that style should rarely be used for a long-term implementation, because of the precedence issue you bring up and because these usages will be scattered throughout the sites with no possibility to make them consistent in the future. But the mechanism can be especially valuable during prototyping, and matches existing affordances in HTML.

data- is an excellent suggestion, I'll just steal that idea right now.

I'm not sure what would be used to validate style. Just the core Sanitizer.php? See also T37704 I guess.

Yes exactly, Sanitizer::fixTagAttributes seems to be used in other places and does some level of security sanitization of the more dangerous CSS keywords like "url".

I'm not sure I get what you're thinking about here for class though, even after coming to know what a ChipInput is.

Sorry for the jargon—for those playing along at home, ChipInput is a built-in MediaWiki component which splits up entered text into little bubbles. My idea here is that VE might show a "class" field when you click to edit a reference list, and that field can be used to add or remove additional styles defined by Cite, or defined by the wiki. Something like this:

image.png (67×412 px, 5 KB)

The field could include some auto-completion when VE can figure out which CSS classes are applicable, but free-form names are also allowed and these might rely on class rules defined in Common.css or in TemplateStyles.

I'm not sure I get what you're thinking about here for class though, even after coming to know what a ChipInput is.

My idea here is that VE might show a "class" field when you click to edit a reference list, and that field can be used to add or remove additional styles defined by Cite, or defined by the wiki. Something like this:

image.png (67×412 px, 5 KB)

The field could include some auto-completion when VE can figure out which CSS classes are applicable, but free-form names are also allowed and these might rely on class rules defined in Common.css or in TemplateStyles.

Ok, that's what I thought you were suggesting.

I've come to a conclusion here also after moving A LOT of CSS out of Common.css into TemplateStyles that it's more healthy for the template to expose parameters that allow the users to flip the bits, e.g. |scroll=yes as a specific example, rather than accepting freeform classes. (Some 'meta'-templates are the exception, and in those cases the exception should be used for a downstream template to employ its own templatestyling.) This allows the template editor to decide what should/shouldn't be supported out in the wild rather than needing to assume that every single class under the sun should be supported in a template (and getting the associated bug reports when things don't even if they weren't intended to). It also allows the template editor to change class names at a later date or the implementation e.g. using two classes rather than one.

As a particular example, when I migrated hlist styles to TemplateStyles I needed to build a class finder for Module:Navbox because hlist was literally in the class parameter rather than in some sort of parameter specifically provided to support horizontal lists in the navbox.

I think the improvement to TemplateData might still be valid (as I think also for style), but I do think this use case encourages a bad pattern (I guess just as with the style suggestion for TemplateData).

Hmm, one other thing I've been mulling:

MediaWiki messages with the entire sequence of symbols, for example lower-alpha.

I would really like it if we could fix this one somehow with whatever The One True Way will be. One of the benefits of the CSS way is that we got a fix here for free. A few of the most pathological pages cite the same source several hundred/thousands of times. IDK what the right answer here is.

MediaWiki messages with the entire sequence of symbols, for example lower-alpha.

I would really like it if we could fix this one somehow with whatever The One True Way will be. One of the benefits of the CSS way is that we got a fix here for free. A few of the most pathological pages cite the same source several hundred/thousands of times. IDK what the right answer here is.

What do you think about T377936: [Epic] Cite to support all known alphabets as footnote marker symbols? The idea is that CLDR can provide known alphabets for each locale, admins can choose how to assign custom group names a specific alphabet, and then Cite (both legacy and Parsoid rendering) will generate a footnote mark dynamically built using that alphabet, following the "a…z, aa, ab…" pattern.

I think that should be good.

Less commonly, the template extends beyond the reference list to its container: setting the section title and style, and suppressing the edit links. This will be left out of scope for now.

This is a discussion point in T364830, but probably deserves its own task. I'm not personally a fan of it in the slightest.

Just to clarify: that task was created because of a problem I was solving, namely, subpages with dynamic content sometimes including references in their output and those references not being displayed nicely. The code there removed a whole bunch of worse solutions to this problem from editors (like putting a References template for a reference not in the page and then that references list becoming empty if it gets deleted, or hiding references on every subpage individually), at no cost to anyone but mobile app users. AFAIK Dutch Wikipedia also uses a template for showing all of their references in a box: https://nl.wikipedia.org/wiki/Sjabloon:Appendix It is also something that could be used in a template like https://en.wikipedia.org/wiki/Template:Reflist-talk
(But personally, I was fine with solving that task by not showing an empty references list in Parsoid read view output.)

Broader point: I think it is fine to see what things wikis do and try to help wiki authors with smaller things, like display configuration etc. I don’t think it is in any way wise to try to make it so reflist syntax contains everything that ever was done on a wiki because of the same structural problem as I described 6 years ago in T95543#4132411, which boils down to this: sure, you might develop all those features, but who would own their maintenance and continued improvement? So I don’t think things like scroll containers should ever be in the extension. Similarly, I was not a big fan of some of the proposals in T364830, but I felt like agreeing to something would be better to solve the issue faster. Cite extension has a lot of unresolved problems, it feels like time would be better spent on honing out things that are common/needed instead of providing a full feature-set.

(Procedural note: although CSS data- attributes are good, they cannot be used for free-form values, like data-column-width="20em", so there would still be a need to have either a wrapper template for cases like that or CSS variable support in styles [but that solution would also be in a template since requiring users to write <references style="--column-width: 20em" /> in wikitext seems pretty bad].)

Broader point: I think it is fine to see what things wikis do and try to help wiki authors with smaller things, like display configuration etc. I don’t think it is in any way wise to try to make it so reflist syntax contains everything that ever was done on a wiki because of the same structural problem as I described 6 years ago in T95543#4132411, which boils down to this: sure, you might develop all those features, but who would own their maintenance and continued improvement? So I don’t think things like scroll containers should ever be in the extension. Similarly, I was not a big fan of some of the proposals in T364830, but I felt like agreeing to something would be better to solve the issue faster. Cite extension has a lot of unresolved problems, it feels like time would be better spent on honing out things that are common/needed instead of providing a full feature-set.

(Procedural note: although CSS data- attributes are good, they cannot be used for free-form values, like data-column-width="20em", so there would still be a need to have either a wrapper template for cases like that or CSS variable support in styles [but that solution would also be in a template since requiring users to write <references style="--column-width: 20em" /> in wikitext seems pretty bad].)

Thanks for the good point and for the links. I would trust your judgment as an editor more than my own developer perspective, especially on this topic. But I believe it's still unclear where the best balance can be found between MediaWiki built-in functionality and on-wiki customizations. My concept in the suggestions coming out of this investigation is an attempt to find this balance: MediaWiki can provide the structure and the extensibility, which allow sites to customize the rendering however they wish, through standardized CSS classes.

To fit into my suggested framework, your last example would be adjusted like this:

  • An editor identifies the need for 20em reference list columns. No site consensus is required yet.
  • This editor experiments with a personal stylesheet and adds a rule something like this: .reflist { column-width: 20em; }
  • If the site likes this style, they can apply it to all reference lists on the whole site.
  • Alternatively, the rule can be written so that it's applied conditionally according to a special class: .reflist-narrow-columns { column-width: 20em; } . This class can be applied to a reflist in a template or in wikitext like <references class="reflist-narrow-columns" />.

CSS variables or RDFa data attributes would only be used for very special effects, I agree that neither is a good experience for users. To follow my example in the task description, this would be implemented using a CSS rule like .reflist[data-columns=5] { column-width: 20em; } but as I say, only for rare edge case stuff.

I don't want to get into the whole philosophical question of presentation vs. content, other than to emphasize that CSS is built for exactly this type of usage. Once the content has a predictable DOM structure, CSS can be applied in a way that's highly decoupled from the HTML content itself.

Restricted Application added a subscriber: alaa. · View Herald TranscriptMay 9 2025, 1:00 PM
awight claimed this task.

Closing as the investigation is complete. Please feel free to continue discussion here!