Module talk:Citation/CS1

From OpenStreetMap Wiki
Latest comment: 12 days ago by Chris2map in topic Parameter list
Jump to navigation Jump to search

Lua rewrite

I've imported this module and a new set of citation templates for use in articles. I started this effort during WikiCredCon 2026 while I had the attention of some Wikipedians who were experienced with citations there. For now, the very simple templates that use this module are all in /sandbox subpages such as {{Cite web/sandbox}}. After we work through any showstopping issues, I'll replace the existing templates with these sandboxed versions.

The current suite of templates is unmaintained and would be extremely difficult to maintain in their current form. They've hardly been modified since 2010–2012. In 2013, Wikipedia replaced the templates with more powerful versions based on this Lua module, but in some cases we intentionally imported outdated versions of the templates because we hadn't installed the Scribunto extension. After we finally installed that extension in 2018, we converted many other complex template systems to Lua, such as {{Convert}}, {{Languages}}, and {{Tag}}. The citation templates are the last major holdover from the old system.

Citations aren't as important on this wiki as they are on Wikipedia. However, some articles and proposals do cite sources (typically forum or mailing list discussions) for claims that may potentially be controversial or unintuitive to a layperson. Additionally, the OpenHistoricalMap project is experimenting with extended bibliographies on this wiki to provide additional commentary and avoid duplicating metadata on countless source=* tags.

The Lua rewrite has a number of advantages over the old template system. I won't list them all here, but some are especially noteworthy for this wiki:

  • Lua is a real programming language, not a macro language. Modifying the behavior still isn't always straightforward, but it's a lot more straightforward than balancing deeply nested curly braces.
  • Pages that transclude the citation templates many times are less likely to run into the template expansion limit. There are separate limits on Lua memory usage and processing time. If we run into those limits, we'll have more options for addressing them.
  • The module supports all the parameters that the English Wikipedia version does. This makes it more likely that users familiar with Wikipedia will get what they expect when inserting citations here. The generated markup will be more compatible with the visual editor. Tools like Cite Unseen will be able to support citations generated by this module.
  • This module includes some more nuanced parameters, so that you can cite chapters within books and sections in maps without worrying about one parameter canceling out another by accident.
  • If a parameter is normally followed by a period but its value happens to end in a period, this module collapses the two periods. An author's middle initial is correctly formatted, so |last = Smith |first = John J. becomes "Smith, John J.", not "Smith, John J.." As seen in OpenStreetMap Americana#References, we no longer have to remember to type |publisher = OpenStreetMap U.S to get "OpenStreetMap U.S." instead of an awkward "OpenStreetMap U.S.."
  • The |ref = harv parameter is no longer required. Every citation has a named anchor by default. This is useful when nesting repeated references inside {{Sfn}}.

There are still some caveats and limitations to discuss before deploying this module more widely:

  • The module is biased towards the wiki's default language (English). Various format strings are English, |language = en is hidden, date formats are validated based on English, and preview-only warnings and errors are in English, linking to documentation on the English Wikipedia. But the preexisting templates were also biased towards English. I'm confident that the Lua modules would be easier to internationalize than the old templates. Maybe we can graft in targeted improvements from multilingual wikis such as Wikimedia Commons. (I didn't copy the module from there because their output is fairly messy.) These improvements can come after replacing the templates.
  • The module automatically adds articles to a variety of tracking categories, none of which have been created yet. Some track usage errors, while others track non-English sources. I suspect we don't have any need for the latter.
  • In the 12–16 years since we imported the English Wikipedia's citation templates, and in the 13 years since the English Wikipedia migrated to this Lua module, the English Wikipedia has made many changes to the expected parameters and parameter names. Each change was accompanied by a generous deprecation period that has long since expired. We're coming in late, so our uses of old parameters like |trans_title = and |deadurl = yes are hard errors (in favor of |trans-title = and |url-status = dead, respectively). I'm unsure how big of a problem this is in general. If folks are concerned, we could instrument the existing templates with temporary tracking categories to find out how many errors we'll need to fix.

 – Minh Nguyễn 💬 23:12, 18 April 2026 (UTC)Reply

Would it make sense to add new parameters to the existing template to migrate their uses first or do we just update everything at once? Wynndale (talk) 15:29, 19 April 2026 (UTC)Reply
@Wynndale: It might be possible to restore the migration period for some of the parameters where the change was purely cosmetic, such as |mailinglist = versus |mailing-list =, or for no-ops like |ref = harv. However, others would be less straightforward, such as |deadurl = yes. I’m just unsure that these issues are widespread enough to matter.
As a test, I migrated every citation template in the OHM pages and found less than a dozen out of hundreds that needed attention. Most of the changes were to take advantage of new capabilities, like the aforementioned trailing periods and language codes in |language =.
Another possibility would be to migrate some templates before others. After I did that test, {{Cite book}} is used on only 74 more pages, which would be straightforward to examine by hand. I’ve already migrated the majority of uses of {{Cite journal}} to the sandboxed version. The most challenging one will be {{Cite web}}, which is used on 338 pages.
 – Minh Nguyễn 💬 17:14, 19 April 2026 (UTC)Reply
I just switched {{Cite journal}} to the new Lua version because there are 3 pages only left using it. Seems to be fine. --Chris2map (talk) 11:43, 9 May 2026 (UTC)Reply

Parameter list

@Minh Nguyen: Is there a parameter list of the parameters currently supported by the module, that could be consulted when creating TemplateData for the templates, e.g. for {{Cite journal}}? I think https://en.wikipedia.org/wiki/Template:Cite_journal#TemplateData doesn't fully match. --Chris2map (talk) 12:06, 9 May 2026 (UTC)Reply