Template talk:Pagelist
![]() | This template does not require a rating on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | |||||||
|
Request to implement editorproof version
[edit]{{editprotected}} I recommend to implement the code on {{Pagelist/sandbox}}. See Template_talk:Merge#Problem_when_using_with_templates for the reason, and that I tested this. Debresser (talk) 06:29, 4 October 2009 (UTC)
Done. Cheers, Skomorokh, barbarian 07:12, 4 October 2009 (UTC)
- I am so proud. Thank you. Debresser (talk) 17:34, 4 October 2009 (UTC)
Version which allows use of multiple namespaces
[edit]There's an example of this template at MediaWiki.org with an additional setting allowing you to use each parameter's namespace rather than one standard namespace for all pages: mw:Template:Pagelist --Varnent (talk) 01:13, 7 January 2012 (UTC)
Range support
[edit]Hi,
I've added backward-compatible support for beginning and ending ranges: Template:Pagelist/sandboxRange
New parameters:
- begin - beginning of the page range; defaults to 1
- end - end of the page range
- preLink - content to add at the beginning the link; defaults to empty string
- postLink - content to add at the beginning the link; defaults to empty string
I'm not sure what the page object is about so I don't know if the new preLink/postLink params should tie into that at all, but at least the new code shouldn't break anything. Brettz9 (talk) 13:47, 21 December 2013 (UTC)
Feedback, if not incorporation into the existing template would be most welcome! Brettz9 (talk) 00:48, 3 January 2014 (UTC)
Some improvment
[edit]@Mr. Stradivarius: Hi! Maybe some functionality could be added to module? What I mean is to make changes, so it could be used in this kind of templates, where there is something more to the page link. --Edgars2007 (talk/contribs) 06:31, 10 January 2015 (UTC)
- @Edgars2007: Sure, go ahead! As long as the existing functionality is kept intact it should be fine. — Mr. Stradivarius ♪ talk ♪ 08:59, 10 January 2015 (UTC)
- @Mr. Stradivarius: ha-ha :) Actually, I wanted to know, if you could make those changes, as I'm sure it won't be a problem to you. --Edgars2007 (talk/contribs) 10:48, 10 January 2015 (UTC)
Edit request
[edit]![]() | This edit request to Module:Pagelist has been answered. Set the |answered= parameter to no to reactivate your request. |
Could the default standard for this module to return the namespace of the page it is used on be removed? I'm trying to fix a long-standing issue with Template:Merge, and I think the resolution would be to replace all instances of [[:{{{nspace|{{NAMESPACE}}}}}:{{PAGENAME:{{{NUMBER}}}}}|{{{NUMBER}}}]]
with [[:{{{NUMBER}}}]]
(if this template weren't Lua-ized), but I have no idea how to do that same task on the Lua module. Steel1943 (talk) 22:34, 26 February 2015 (UTC)
- @Steel1943: You would do this. But might this change not break some of the existing transclusions? I don't know why the original template did it that way, but perhaps some pages somewhere are relying on that behaviour. — Mr. Stradivarius ♪ talk ♪ 03:11, 27 February 2015 (UTC)
- @Mr. Stradivarius: I was thinking the same. This change would potentially negatively affect all pages that transclude this template that are in any namespace other that the article namespace. However, I noticed that there are about 12000 transclusions, but I noticed that most of them (probably 95% of them) are in the article space. I'm planning on picking through the ones in the non-article spaces here in a few and force the use of the
nspace=
parameter in them so that this change can happen with no negative effects. Steel1943 (talk) 03:24, 27 February 2015 (UTC)- ...And since I now realized that forcing the
nspace=
parameter is technically impossible (without editing every template that transcludes {{Pagelinks}}), I'm now going to attempt to compile a list of pages (a count) of the amount of pages that could negatively be affected by this change. The only other option would be a three-step process where first, all templates that transclude {{Pagelinks}} are edited to allow thenspace=
parameter to be utilized, force the parameter in all transclusions of the template (that are not templates themselves), then perform the edit I requested. But, unless this edit happens, it's technically impossible to list pages from multiple namespaces in this template. Steel1943 (talk) 03:34, 27 February 2015 (UTC)- Actually, at this point, I'm probably going to work on removing/fixing all non-article namespace transclusions. I've been doing so right now, and am actually probably close to being done. I'll update this section when I am done, or run across a complication. Steel1943 (talk) 04:07, 27 February 2015 (UTC)
- I'm going to mark this "answered" until I can figure out/fix the non-article space transclusions. (That, and I actually don't want to completely remove the
nspace=
parameter as my request above is suggesting. I'm going to revisit this after I fix the existing non-article space transclusions.) Steel1943 (talk) 04:25, 27 February 2015 (UTC)
- I'm going to mark this "answered" until I can figure out/fix the non-article space transclusions. (That, and I actually don't want to completely remove the
- Actually, at this point, I'm probably going to work on removing/fixing all non-article namespace transclusions. I've been doing so right now, and am actually probably close to being done. I'll update this section when I am done, or run across a complication. Steel1943 (talk) 04:07, 27 February 2015 (UTC)
- ...And since I now realized that forcing the
- @Mr. Stradivarius: I was thinking the same. This change would potentially negatively affect all pages that transclude this template that are in any namespace other that the article namespace. However, I noticed that there are about 12000 transclusions, but I noticed that most of them (probably 95% of them) are in the article space. I'm planning on picking through the ones in the non-article spaces here in a few and force the use of the
Oxford commas, please
[edit]![]() | This edit request to Module:Pagelist has been answered. Set the |answered= parameter to no to reactivate your request. |
This template prints the last two article names separated by " and ". It would be helpful to use ", and " instead. The main reason is that "and" is often a word within an article name, so failure to set off the conjunction with a comma can confuse readers by implying that the last two names are a single article name. Link coloring is not always a sufficient visual cue.
Example: {{Pagelist|nspace=w|Frick and Frack|Mutt and Jeff|Madonna|Child}}
Current output: Frick and Frack, Mutt and Jeff, Madonna and Child.
Desired output: Frick and Frack, Mutt and Jeff, Madonna, and Child.
Please consider implementing this as an option rather than a change to default behavior, because lists with only two items should not be separated by commas. This change should not break any existing usage. — ℜob C. alias ALAROB 14:47, 7 April 2015 (UTC)
- You can use
|conjunction=
:Frick and Frack, Mutt and Jeff, Madonna, and Child.{{Pagelist|nspace=w|conjunction=, and |Frick and Frack|Mutt and Jeff|Madonna|Child}}.
Alakzi (talk) 15:10, 7 April 2015 (UTC)
- Thanks, Alakzi. — ℜob C. alias ALAROB 15:36, 7 April 2015 (UTC)
- I see that the
conjunction
parameter already existed and I overlooked the guidance in Help. I did read it before making the request, but apprently I didn’t comprehend it. - I find that I have to add a non-breaking space after ", and " because a space will be ignored, as here:
- Muslim population growth, Ali, andThe Conversation of Eiros and Charmion
{{pagelist |nspace=w|conjunction=, and |Muslim population growth|Ali|The Conversation of Eiros and Charmion}}
- Same thing happens if I paste your demo:
- Frick and Frack, Mutt and Jeff, Madonna, andChild.
{{Pagelist|nspace=w|conjunction=, and |Frick and Frack|Mutt and Jeff|Madonna|Child}}.
- But this works: {{Pagelist|nspace=w|conjunction=, and |Frick and Frack|Mutt and Jeff|Madonna|Child}}</nowiki>
- Why are you and I getting different results? — ℜob C. alias ALAROB 16:00, 7 April 2015 (UTC)
- We're not; I used alt-space to type a non-breaking space because it's quicker. It gets copied as a regular space. Apologies for the confusion. Alakzi (talk) 16:05, 7 April 2015 (UTC)
- To add, there's no workaround for this—that I know of; leading and trailing whitespace inside parameters always gets stripped. Alakzi (talk) 16:09, 7 April 2015 (UTC)
- OK. That did the trick. Thanks. — ℜob C. alias ALAROB 16:32, 7 April 2015 (UTC)
- One can also use
 
instead of
. See Template:Pagelist#Examples. One character shorter, but maybe even less readable, unless you have memorized some ASCII codes. — Chrisahn (talk) 15:11, 30 August 2025 (UTC)
- One can also use
- OK. That did the trick. Thanks. — ℜob C. alias ALAROB 16:32, 7 April 2015 (UTC)
- This didn't really resolve the issue. See next thread. — SMcCandlish ☺ ☏ ¢ ≽ʌⱷ҅ᴥⱷʌ≼ 03:41, 8 November 2015 (UTC)
Serial comma default when 3+ list items
[edit]This should use the serial (a.k.a. Oxford) comma by default when there are three or more items. This often produces difficult-to-parse output because of the lack of this comma, and virtually no one is going to manually inject one with a special parameter. Even American style guides like Chicago Manual of Style recommend the use of a serial comma in any case where it aids comprehension, so its use is not "against the rules" anywhere. The |conjunction=
parameter is of broken utility anyway, since it will also insert a comma before "and" when there are only two items, which is almost never desirable (only when the two items are complex and contain their own punuctation, in which case a semicolon is often better anyway). — SMcCandlish ☺ ☏ ¢ ≽ʌⱷ҅ᴥⱷʌ≼ 03:41, 8 November 2015 (UTC)
Use the serial comma by default
[edit]Implement the serial comma requested by SMcCandlish and others in the 2 previous discussions above. There is consensus this should at least be the default. The |conjunction=
parameter only adds a comma when less than three items are present.
This template needs a serial comma the most, as it is often used to list many long page names. This also should be done to comply with MOS:SERIAL, which says:
Serial commas are more helpful when article text is complex, such as a list with multi-word items or a series of probably unfamiliar terms.
In most cases where this template is used, both of these apply, and in practically all cases it is used, at least the first ("multi-word items") applies, as it is used for links to articles. Additionally, there are no cases in which this could create confusion, as it's not used for sentences. FaviFake (talk) 14:21, 24 August 2025 (UTC)
Not done: please make your requested changes to the template's sandbox first; see WP:TESTCASES. Module:Pagelist/sandbox is not protected. Go for it. – Jonesey95 (talk) 00:06, 26 August 2025 (UTC)
- Jonesey95 I made an ER because I don't know how to do it myself. I can mess around with wikitext code, but Lua modules are a different beast. Could you do it for me? FaviFake (talk) 09:06, 30 August 2025 (UTC)
- I had a look at the Lua source code, and I think the text containing the commas is generated by this call:
mw.text.listToText(t, separator, conjunction)
. The examples in the documentation for mw.text.listToText look like there's no convenient way to make the function generate a serial comma. I guess the best option might be to use ", and " (including the comma) for theconjunction
parameter. But we can't simply use a comma plus "and", we have to concatenate the actual values ofseparator
andconjunction
from the template invocation. — Chrisahn (talk) 11:08, 30 August 2025 (UTC)- Source code of
mw.text.listToText
on GitHub: [1]. The linesseparator = separator or options.comma
andconjunction = conjunction or options['and']
load the defaults from theoptions
table. Theoptions
table is set up here: [2]. I think the expression'and' => wfMessage( 'and' )->inContentLanguage()->text() . wfMessage( 'word-separator' )->inContentLanguage()->text()
loads (and concatenates) the content of MediaWiki:and (which is " and", starting with a normal ASCII 0x20 space) and MediaWiki:word-separator (which is " ", a normal ASCII 0x20 space), so the default conjunction is " and ". Chrisahn (talk) 22:08, 30 August 2025 (UTC)
- Source code of
- I had a look at the Lua source code, and I think the text containing the commas is generated by this call:
- Jonesey95 I made an ER because I don't know how to do it myself. I can mess around with wikitext code, but Lua modules are a different beast. Could you do it for me? FaviFake (talk) 09:06, 30 August 2025 (UTC)
- "There is consensus this should at least be the default." I don't see consensus for this. There's the 2015 comment by SMcCandlish, but that's it... — Chrisahn (talk) 11:17, 30 August 2025 (UTC)
- There's also the request by @Alarob above it, and mine. So that's about 3 total editors proposing this change; i'd say it's a consensus, although weak. FaviFake (talk) 11:21, 30 August 2025 (UTC)
- Alarob didn't ask to change the template but said "That did the trick. Thanks." in the end. Sounds like that request was completed. Anyway, I think we should first discuss (a) whether we really want to change the template and (b) in what way exactly: Should the template always insert a serial comma if there are more than two items? Or should we add a template parameter to make this configurable? This template is used on approximately 4,800 pages... — Chrisahn (talk) 11:29, 30 August 2025 (UTC)
- Alright, let's start!
Should the template always insert a serial comma if there are more than two items? Or should we add a template parameter to make this configurable?
I'd say it should be the default and it can be turned off manually with another parameter, for the reasons I explained in my first comment. It shouldn't be required in every instance.This template is used on approximately 4,800 pages...
Sure, but this is a very minor edit.Wdyt? FaviFake (talk) 11:34, 30 August 2025 (UTC)- "should be the default and it can be turned off" – Sounds good to me, but we should wait for other opinions.
- "this is a very minor edit" – A minor edit that affects thousands of pages is a major change. — Chrisahn (talk) 11:40, 30 August 2025 (UTC)
Sounds good to me, but we should wait for other opinions.
I agree! This discussion was started 5 days ago, and nobody else has chimed in yet. Should we attract more editors to this discussion in more ways? FaviFake (talk) 11:45, 30 August 2025 (UTC)- Yes, that would be good. Maybe post on Wikipedia talk:WikiProject Templates? Or is there a better way to invite others to this discussion? — Chrisahn (talk) 12:00, 30 August 2025 (UTC)
- I honestly have no idea, I wasn't even aware of that WP. Thanks. FaviFake (talk) 12:02, 30 August 2025 (UTC)
- Your account wrote something on that page two weeks ago, but I guess that was done by a script. :-) — Chrisahn (talk) Chrisahn (talk) 12:07, 30 August 2025 (UTC)
- Oh you're right! Probably, yeah. FaviFake (talk) 12:20, 30 August 2025 (UTC)
- Your account wrote something on that page two weeks ago, but I guess that was done by a script. :-) — Chrisahn (talk) Chrisahn (talk) 12:07, 30 August 2025 (UTC)
- I honestly have no idea, I wasn't even aware of that WP. Thanks. FaviFake (talk) 12:02, 30 August 2025 (UTC)
- Yes, that would be good. Maybe post on Wikipedia talk:WikiProject Templates? Or is there a better way to invite others to this discussion? — Chrisahn (talk) 12:00, 30 August 2025 (UTC)
- Alright, let's start!
- Alarob didn't ask to change the template but said "That did the trick. Thanks." in the end. Sounds like that request was completed. Anyway, I think we should first discuss (a) whether we really want to change the template and (b) in what way exactly: Should the template always insert a serial comma if there are more than two items? Or should we add a template parameter to make this configurable? This template is used on approximately 4,800 pages... — Chrisahn (talk) 11:29, 30 August 2025 (UTC)
- There's also the request by @Alarob above it, and mine. So that's about 3 total editors proposing this change; i'd say it's a consensus, although weak. FaviFake (talk) 11:21, 30 August 2025 (UTC)
- I tried Special:WhatLinksHere/Template:Pagelist to find articles that might be affected by this change, but none of the pages I checked seem to use this template directly, at least I can't find it in the source. I guess there's some indirect use, but I can't find that either. What am I doing wrong? — Chrisahn (talk) 12:14, 30 August 2025 (UTC)
- I guess you could inspect the code of every template transcluded in a page on that list, and then if you don't find it open every template that's inside that template, but yeah that would be very time consuming. I'm no expert so there ight be other ways or tools that I'm unaware of. FaviFake (talk) 12:23, 30 August 2025 (UTC)
- I think I got it. {{Pagelist}} is used in {{Merge}}, {{Merge from}}, {{Split}}, etc. I looked at a dozen pages from Special:WhatLinksHere/Template:Pagelist, and all of them use on of these templates. In most cases, they only reference one page though. In a nutshell: The claim that {{Pagelist}} is used in 4800 pages is completely bogus. — Chrisahn (talk) 12:32, 30 August 2025 (UTC)
- Wait, maybe the merge templates that only include just 1 page have a "pagelist" composed of just one page? This would mean that this edit would affect much, much less pages. FaviFake (talk) 12:35, 30 August 2025 (UTC)
- Exactly. :-) — Chrisahn (talk) 12:38, 30 August 2025 (UTC)
- Soo... this means this consensus among 2-3(-4?) people with no opposition should be enough. Should I go ahead and reinstate the ER? FaviFake (talk) 12:41, 30 August 2025 (UTC)
- Yeah, sounds good to me. — Chrisahn (talk) 12:47, 30 August 2025 (UTC)
- Soo... this means this consensus among 2-3(-4?) people with no opposition should be enough. Should I go ahead and reinstate the ER? FaviFake (talk) 12:41, 30 August 2025 (UTC)
- Exactly. :-) — Chrisahn (talk) 12:38, 30 August 2025 (UTC)
- Wait, maybe the merge templates that only include just 1 page have a "pagelist" composed of just one page? This would mean that this edit would affect much, much less pages. FaviFake (talk) 12:35, 30 August 2025 (UTC)
- I think I got it. {{Pagelist}} is used in {{Merge}}, {{Merge from}}, {{Split}}, etc. I looked at a dozen pages from Special:WhatLinksHere/Template:Pagelist, and all of them use on of these templates. In most cases, they only reference one page though. In a nutshell: The claim that {{Pagelist}} is used in 4800 pages is completely bogus. — Chrisahn (talk) 12:32, 30 August 2025 (UTC)
- I tried Special:Search/insource:pagelist instead. It looks like exactly one page actually uses this template directly. A somewhat smaller number than 4,800. :-) Chrisahn (talk) 12:46, 30 August 2025 (UTC)
- Wow, just one! FaviFake (talk) 12:50, 30 August 2025 (UTC)
- Yeah. Makes me wonder if this is actually worth the effort... Maybe the template was used more often in 2015 when the requests above were posted. — Chrisahn (talk) 12:52, 30 August 2025 (UTC)
- Possible, but with this change it can be used by future editors in future templates, or to improve current ones. I suspect some templates have manually-coded lists when they could easily use this module. FaviFake (talk) 12:57, 30 August 2025 (UTC)
- The page is Nanoparticle#Compounds by industrial area, and in this case the Oxford comma wouldn't make a significant difference. The lists are easily readable without it. — Chrisahn (talk) 12:57, 30 August 2025 (UTC)
- And there are probably a few other merge templates that use it, and they probably have longer page names (if they need to be merged, teir titles are usually specific). So it's likely not just one page, luckily :) FaviFake (talk) 13:00, 30 August 2025 (UTC)
- Yes, there are a few more templates. Roughly two dozen templates, the other search results are bogus. — Chrisahn (talk) 13:17, 30 August 2025 (UTC)
- And there are probably a few other merge templates that use it, and they probably have longer page names (if they need to be merged, teir titles are usually specific). So it's likely not just one page, luckily :) FaviFake (talk) 13:00, 30 August 2025 (UTC)
- Yeah. Makes me wonder if this is actually worth the effort... Maybe the template was used more often in 2015 when the requests above were posted. — Chrisahn (talk) 12:52, 30 August 2025 (UTC)
- Wow, just one! FaviFake (talk) 12:50, 30 August 2025 (UTC)
- This search criterion seems to work well: insource:pagelist insource:/"{{pagelist"/i It finds 231 uses of {{Pagelist}} in total. — Chrisahn (talk) 23:49, 30 August 2025 (UTC)
- 155 in the Wikipedia namespace, but I found only one "handwritten" case: Wikipedia:Village pump (miscellaneous)/Archive 14#Parent project adoption needed (from 2008). Other uses in the Wikipedia namespace are generated by scripts: 41 Articles for deletion discussions, 113 Proposed mergers log pages. — Chrisahn (talk) 23:44, 30 August 2025 (UTC)
- 3 in namespace User talk, mostly with a single page, except User talk:CBDunkerson/Frank#Annoyances with Wikirendering or something — Chrisahn (talk) 00:09, 31 August 2025 (UTC)
- 1 use in Category talk: Category talk:Naval ships of the United States#Parent Cat Trees — Chrisahn (talk) 00:03, 31 August 2025 (UTC)
- 1 in namespace Module: Module:Params/doc/examples/constructed transclusion/doc — Chrisahn (talk) 00:04, 31 August 2025 (UTC)
- 2 in Wikipedia talk, not interesting — Chrisahn (talk) 00:15, 31 August 2025 (UTC)
- I guess you could inspect the code of every template transcluded in a page on that list, and then if you don't find it open every template that's inside that template, but yeah that would be very time consuming. I'm no expert so there ight be other ways or tools that I'm unaware of. FaviFake (talk) 12:23, 30 August 2025 (UTC)
I use this template on my user page with parameters that replace commas with a pair of colons (: :). {{pagelist |nspace=w |separator= ''': :''' |conjunction= ''': :'''
I would need to turn off the default ", and ". That said, I'm inclined to support the edit request because it prevents confusion when reading a series of article names. I was quoted above as signing off on the template as it is now, and it does work for me. But I also believe that most users would find the solution too technical or obscure, e.g. having to insert a non-breaking space character. — ℜob C. alias ALAROB 21:34, 30 August 2025 (UTC)
- Thanks for the interesting usage example! If the serial comma ("Oxford comma") becomes the default, it won't really be a comma, it will be the separator. More precisely: The default string for the last item separation won't be
", and "
, it will the concatenation of the separator, a space, and the conjunction. The default separator is ", ", and the default conjunction is " and ", but both can be configured via template parameters. In your case, the separator and the conjunction have the same value''': :'''
, so the string for the last item separation would be''': :''' ''': :'''
, which is of course not what you want. I thought you could avoid this by setting the conjunction to an empty value, but Module:Pagelist currently treats empty values as missing, so the conjunction would be the default " and ", which also isn't what you want. As usual, even a simple change like this is pretty complex. I'm not sure yet how to best implement this... — Chrisahn (talk) 22:54, 30 August 2025 (UTC)- I tried it in Module:Pagelist/sandbox – we can easily allow empty values for
separator
andconjunction
. If we do that and also make the "serial separator" the default, you can simply change your template invocation from{{pagelist |separator= ''': :''' |conjunction= ''': :'''}
to{{pagelist |separator= ''': :''' |conjunction= }
, and you're done. — Chrisahn (talk) 17:42, 31 August 2025 (UTC)- Ouch, no, this doesn't work. If there are exactly two pages, we only use the conjunction, not the separator. Or maybe... See below. — Chrisahn (talk) 22:41, 31 August 2025 (UTC)
- I tried it in Module:Pagelist/sandbox – we can easily allow empty values for
Actually implementing it
[edit]Alright, I'll advertise this at WP:VPT to try and attract someone who can actually code this in the sandbox. There is consensus to implement the change. (The consensus was reached starting from this comment in the section above.)
Currently, the Module:Pagelist doesn't use serial (Oxford) commas when there are 3 or more items in a list. For various reasons, it needs to use it by default, and a parameter should be created to allow editors to turn it off manually. The testcases where this should be tested is at Template:Pagelist/testcases. We aren't currently able to perform this change, so we'd like some help. Thanks! FaviFake (talk) 21:27, 31 August 2025 (UTC)
Done FaviFake (talk) 21:30, 31 August 2025 (UTC)
- I'd be happy to implement the change, writing the code is no big deal. But I don't think we're ready yet.
- Are we sure that this won't break any existing uses of the template? I did some searching and so far it looks good, but there are still some more checks we should do.
- What should be the name of the template parameter that switches off the serial separator behavior?
- What's the exact specification? I guess the following:
- If the
separator
template parameter is missing, the default value ", " is used - If the
separator
template parameter is empty, the empty string "" is used - If the
conjunction
template parameter is missing, the default value " and " is used - If the
conjunction
template parameter is empty, the empty string "" is used - When the serial separator is switched off (by the appropriate parameter), the template behaves the same as it currently does:
- If one page name parameter is given to the template, the invocation result is that page, without separator or conjunction
- If two page name parameters are given to the template, the invocation result is the concatention of the first page link, the conjunction, and the second page link, e.g. "A and B"
- If n > 2 page name parameters are given to the template, the invocation result is the concatention of the first n-2 page links (where each is followed by the separator), the second to last page link, the conjunction, and the last page link, e.g. "A, B and C"
- When the serial separator is not switched off, the template behaves as follows:
- If one or two page name parameters are given to the template, the behavior is the same as above
- If n > 2 page name parameters are given to the template, the invocation result is the concatention of the first n-1 page links (where each is followed by the separator), the conjunction, and the last page link, e.g. "A, B, and C"
- If the
- I hope I didn't miss any edge cases...
- Or maybe we should treat empty values for
separator
andconjunction
the same as missing values, as before? I just realized that the solution I suggested for Alarob's case above (using an empty conjunction) doesn't work anyway – in the n=2 case, we only use the conjunction, not the separator: we generate "A and B", not "A, and B". With an empty conjunction, that becomes "AB". :-( - — Chrisahn (talk) 22:31, 31 August 2025 (UTC)
- I misunderstood your messages, thanks for correcting me. I'll leave it up for other, more technical users, to review this. --FaviFake (talk) 13:21, 1 September 2025 (UTC)
More options
[edit](Split from #Use the serial comma by default)
Or maybe we should think bigger...
What Alarob above actually wants is to always use the same separator, no matter whether there are two, three or more pages. Just ignore the conjunction.
And look at {{Catlist}}, which invokes {{Pagelist}}: It uses intricate template code to check the separator and/or the conjunction parameters, and chooses the conjunction based on the separator.
For both of these uses, it would be nice if {{Pagelist}} was more flexible. So how about this – instead of a parameter that can only switch the serial separator on or off, let's introduce a parameter with multiple options:
- current behavior, i.e. "A and B" / "A, B and C"
- serial separator if n > 2, i.e. "A and B" / "A, B, and C"
- always serial separator, i.e. "A, and B" / "A, B, and C"
- always serial separator, no conjunction, i.e. "A, B" / "A, B, C"
— Chrisahn (talk) 23:20, 31 August 2025 (UTC)
- Or maybe we should make this template much smarter and do what {{Catlist}} does: Automatically pick the conjunction for a given separator...
- — Chrisahn (talk) 08:35, 1 September 2025 (UTC)
- The option "always serial separator, no conjunction" was (implicitly) requested ten years ago in #Some improvment, pointing to {{NYC bus link}}, which does that unless one sets the
prose
parameter, in which case "and" is the last separator (without an Oxford comma). — Chrisahn (talk) 08:44, 1 September 2025 (UTC)
Switching to Module:Params
[edit]Just out of curiosity, at {{Pagelist/sandbox}} I rewrote the template relying only on Module:Params (instead of Module:Pagelist). I did not capture all the benchmarks, but by switching to Module:Params the template might become twice as fast and way easier to maintain (because editing it will not require knowing Lua). --Grufo (talk) 02:56, 8 September 2025 (UTC)
- Interesting idea, but... Template syntax is messy. Even relatively simple changes can be difficult to implement. For example, in Module:Pagelist, there's a simple table with separator names, e.g. "dot" and "pipe". How would we implement these names in a template? I bet it's possible, but it would not result in easily readable code... I wonder which language is understood by more people – templates or Lua? Maybe among current Wikipedia editors it's templates, but in general it's certainly Lua. Lua is a pretty simple and clean procedural programming language, while MediaWiki templates are written in a rather obscure functional language. Most people who can write and maintain templates shouldn't have difficulties learning Lua. In conclusion, Module:Params may be great for other cases, but I don't think it would be an improvement for this template. It would probably make maintaining this template harder, not easier. Sorry for being a killjoy! — Chrisahn (talk) 17:39, 8 September 2025 (UTC)
- You wrote that Module:Params might be twice as fast as Module:Pagelist. Sounds interesting, but I'm always a bit skeptical regarding performance claims. Did you benchmark both versions? Can you explain why this could be the case? — Chrisahn (talk) 17:41, 8 September 2025 (UTC)
- Hi, Chrisahn.
- “
For example, in Module:Pagelist, there's a simple table with separator names, e.g. "dot" and "pipe". How would we implement these names in a template?
”- Uh I missed it. For that we would need to place a tiny {{#switch:}} where you now see
{{{separator|, }}}
.
- Uh I missed it. For that we would need to place a tiny {{#switch:}} where you now see
- “
Did you benchmark both versions?
”- Yes, but it was not a serious benchmark test, because I only used a section of Template:Pagelist/doc for it. There I saw that with {{Pagelist}} the page took 9 ms of “Lua time usage”, whereas with {{Pagelist/sandbox}} it took 5 ms. For a serious test we would need to create a dedicated page with a couple hundreds of links (i.e. template parameters) to be listed by both {{Pagelist}} and {{Pagelist/sandbox}}, and check the time.
- “
Can you explain why this could be the case?
”- If this held true also in a serious speed test, my guess is that it would be due to the fact that Module:Pagelist invokes expensive Lua functions, like
mw.ustring.gsub()
(in general themw
library has more than one heavy function).
- If this held true also in a serious speed test, my guess is that it would be due to the fact that Module:Pagelist invokes expensive Lua functions, like
- “
- As for what is simpler to use, if Lua or wikitext, I can only guess: concerning the general world population I would probably agree with you, but I would have few doubts that here on Wikipedia wikitext would be by far considered simpler. It makes it also easier to edit the template by only clicking on “Show preview” for tests and intermediate edits, rather than having to save a module and test it from a separate page each time. Bonus point that comes with the code I wrote: I introduced the possibility of using the
$#
placeholder in the|delim=
and|edelim=
paramenters for indicating a link counter. E.g.:{{Pagelist/sandbox|Deolinda Lopes Vieira|Elias Dummer|Sajjan (newspaper)|Piet Bon|Queen's Hall, Edinburgh|delim=''$#.'' |edelim=|conjunction=; |separator=; }}
- ↳ 1. Deolinda Lopes Vieira; 2. Elias Dummer; 3. Sajjan (newspaper); 4. Piet Bon; 5. Queen's Hall, Edinburgh
- (Actually I only let the template inherit the feature from Module:Params). --Grufo (talk) 19:09, 8 September 2025 (UTC)
- The
$#
placeholder is a nice touch. I implemented it in Module:Pagelist/sandbox. (Only for the delimiter though. If we actually wanted to implement this feature, we'd probably have to also replace$#
in other arguments, at least the end delimiter.) (To test the code, I had to revert {{Pagelist/sandbox}} to the version that calls the module. Feel free to revert it back to your version.) — Chrisahn (talk) 21:01, 8 September 2025 (UTC) - Regarding performance: When I tested my code, I wanted to compare two versions. I expected one to be faster. I hit "preview" a couple of times on Template:Pagelist/testcases and looked at Lua time usage. I got values between 110 ms and 190 ms. I didn't see a difference between the two versions. — Chrisahn (talk) 21:05, 8 September 2025 (UTC)
- I switched {{Pagelist/sandbox}} back to your version and again hit "preview" a few dozen times on Template:Pagelist/testcases. I'm getting pretty much the same values for Lua time usage as for my code. I don't see a performance difference, but the measurements are simply too noisy to be useful in this case. Memory usage measurements are more consistent, but all three versions I tested are in the range of roughly 1 MB to 2 MB, so that doesn't matter much either. — Chrisahn (talk) 21:17, 8 September 2025 (UTC)
- The
- Hi, Chrisahn.
@Chrisahn: I am glad I gave you a good idea :) If I paste the following code four times as the only content of a blank page I get between 75 and 100 ms (“Lua time usage”); but if I replace all four transclusion with {{Pagelist/sandbox}} I get between 7 and 10 ms (I still did not do enough tests to give good estimates):
Extended content
|
---|
{{Pagelist|Los Angeles Pobladores|List of people from Los Feliz, Los Angeles|Pari Abasalti|Gene Allen (art director)|Henry Allen (Colorado settler)|Maria Altmann|Jerome Armstrong|Ersi Arvizu|Michele Avila|Gladys Pearl Baker|Louis L. Bard|James R. Barton|Bob Beemer|Esther Belin|Bruce Berry (roadie)|Big U|David Binder|George Birnbaum|Hedda Bolgar|Max Boot|Mike Boots|Boyle–Workman family|Fredrick Brennan|Frank Bresee|Lawrence D. Brown|Killing of Deandre Brunston|Bob Burnside|John Henry Carpenter|Lemuel Carpenter|Angie Chabram-Dernersesian|Charles R. Chamberlain|Dorothy Buffum Chandler|John Edward Chilberg II|Charlotte Clark|Clipper Darrell|Buzzy Cohen|Deborah Cohen (mohelet)|Jack T. Collis|Sunni Colón|Melyda Corado|Mariana W. de Coronel|Ione Virginia Hill Cowles|Elysia Crampton|William J. Creber|Kristin Crowley|Robert Cushman (curator)|Amanda Daflos|Holly Dagres|Damon Alimouri|Leslee Dart|Laura de Seroux|Maureen Dean|Ysabel del Valle|Reginald Oliver Denny|Emil Diedt|Ed Donovan (engine builder)|Tyler Dooley|Margaret Pleasant Douroux|Maria Downey|Laura Ann Doyle|Frederick Eaton|Warren Eckstein|Mark Edward|Cristina Ehrlich|Gladys English|Dentler Erdmann|Disappearance of Christie Farni|Gary Brooks Faulkner|Jayden James Federline|Cecil Fergerson|Marta Feuchtwanger|Michèle Flournoy|Kate M. Foley|Amaryllis Fox Kennedy|K. C. Fox|Dovi Frances|Philip Gale|Marta Felicitas Galedary|Garth Garcia|John J. Garstka|Octavius D. Gass|Nats Getty|Susan Thornton Glassell|Lindy Goetz|Ann Goldstein (curator)|James Goldstein|Pedro J. González|Steven González|Henry C. Gooding|Hridayananda das Goswami|Disappearance of Robin Graham|William A. Greene|Paul Groesse|Vera Guerin|Pedro Guzman|Mike Hallimore|Latasha Harlins|Marc Headley|A. Earl Hedrick|Ric Heitzman|Sudafi Henry|Isaias Hernandez|Chris Hicky|Karin Higa|Daniel Hillel|Garin Hovannisian|Marie T. Huhtala|Anna Graham Hunter|Hugo Huntzinger|Clancy Imislund|Leslie L. Irvin|Joe Jackson (talent manager)|Katherine Jackson|Justinian (Justin) Jampol|Janis Gaye|Richard Jankovich|Monique Jenkinson|Tom Jennings|Liver-Eating Johnson|Bob Devin Jones|Elena Jurado|Marguerite P. Justice|Nobe Kawano|Yosh Kawano|Jim Kepner|Charley Leundeu Keunang|Adele Kibre|Jonny Kim|Marilyn Klaus|Jonathan Philip Klein|Virginia Knight|Stephen Kolzak|Stewart Kosoy|Beatrice Kozera|Whitney Ann Kroenke|Anne Kuljian|Brianna Kupfer|Stewart Kwoh|Leno LaBianca|Rosemary LaBianca|Shawn Landres|Ralph Larkin|Abe Lastfogel|Leon L. Lewis|Eli Russell Linnetz|Adam Lisagor|Lorena David|Mack E. Jenkins|Monroe Alpheus Majors|Chloe Malle|Marquise Jackson|Lee Marshall (announcer)|Don Martinez|Norman Matloff|Roberta McCain|Chris McCandless|Meade McClanahan|Melodie McDaniel|Wilbur McGaugh|George Louis McGhee|Mesmer family of California|Steven Miessner|Goran Milev|Diane Disney Miller|Claudio Miranda|Michael C. Mitchell|Kevin Mitnick|Nobuko JoAnne Miyamoto|Orra E. Monnette|Alan Richard Mootnick|Charles T. Moran|Morojo|Robert Nisbet|Robert Odell|Joyce Nakamura Okazaki|Jack Okey|Dana Okimoto|Marc Okrand|Ray and Anne Ortlund|Harlan G. Palmer|Chuck Panama|Frederick S. Pardee|Murder of Marion Parker|Stephen Paster|Ruth Pearl|Tom Pedigo|Alia Penner|Bill Pettis|Mariana Pfaelzer|George Pickow|Valentina Paloma Pinault|Crystina Poncher|Bertram W. H. Poole|Jack Poplin|Jonathan Fantini Porter|Emily Brown Portwig|Monique Powell|Fred Preble|Frederick K. C. Price|Luis Manuel Quintero|Neil Abramson (filmmaker)|Zackie Achmat|Julia Anastasopoulos|Erricos Andreou|Norman Anstey|Lawrence Anthony|Gina Athans|John Murray, 11th Duke of Atholl|Rosalie Balkin|John Brereton Barlow|Wendy Beckett|Marlene Behrmann|Sinclair Beiles|Arthur Benson|Henry Benson, Baron Benson|Lael Bethlehem|Alex Binaris|Kitty Black|Taddy Blecher|Alexis Bloom|Harry Bloom|Steve Bloom|Ronnie Bosielo|Danie Brits|Michele Bruno|Cornelius Burger|Sarah Calburn|Gaba Cannal|Urzila Carlson|Michael Cassidy (evangelist)|Laloo Chiba|Tom Cloete|Jacques Coetzee and John Frank Brown|Tansey Coetzee|Bertram Cohen (dentist)|George Getzel Cohen|Stanley Cohen (sociologist)|Andrew Colman|Johan Conradie|Catherine Constantinides|H. Basil S. Cooke|Rosemary Feit Covey|Ian Dalrymple|Garth Davis (surgeon)|Bhawani Dayal Sannyasi|Deep Fried Man|Glen Dell|Vergie Derman|Khanyi Dhlomo|Clement Martyn Doke|Jonathan Drummond-Webb|Tracy Edser|Charlotte Ellertson|Jan Eloff|Louise Emanuel|Kendra Oluchi Etufunwa|Maxine Fassberg|Clinton Fein|Anthony Feinstein|Sadie Forman|Sandra Fredman|Frances Gamble|Jonathan Garb|General (musician)|Karin Giannone|Bruce Gordon (actor/director)|Manfred Gorvy|David Gresham|Dulcie Hartwell|Ellen Hellmann|Lindsey Hermer-Bell|Margaret Hewett|Alan Hirsch|Julien Hoffman|Mike Horn|Phil Howard (chef)|Pieter Hugo|Tim Hurson|Daisuke Ishiwatari|Martin Israel|Miriam Janisch|Coleman Jennings|Mike Jensen (internet pioneer)|Jon Joffin|Kurt Jonas|Josiah De Disciple|Fenner Kadalie|Ariel Kaplan|Josh Kempen|Shane Kgoele|Priscilla Kincaid-Smith|Michael David Kirchmann|Leendert Koekemoer|Ross Kriel|Adam Kuper|Liesl Laurie|Robert Z. Lawrence|Moonyeenn Lee|Leka, Prince of Albania|Alan Levin (Internet governance)|Carole Lewis|Jonathan Lewis (oncologist)|Wayne Lotter|Ina Lu|Jeremy Maggs|Gratitude Magwanishe|Thomas Main|John Manduell|Maps Maponyane|Pia Marais|Barbara Masekela|Billy Masetlha|Monica Mason|Andrew Masondo|Boissie Mbha|Phyllis McCarthy|Ray McCauley|Garth Meade|Lauren Mellor|Mike Melvill|Gideon Mendel|Kirti Menon|Nana Meriwether|Norman Middleton|Eric Miller (photographer)|Dan Mindel|Abdul Minty|Bontle Modiselle|Candice Modiselle|Imraan Moosa|Candice Morgan|Mark Mostert|Sizwe Mpofu-Walsh|Mendi Msimang|Shira Nayman|Lerato Ngobeni|Julia Nicol|William Nicol (Transvaal)|Lisa de Nikolits|Christobel Nontenja|Pierre Novellie|Udeme Okon|Ken Oosterbroek|Chloe Orkin|Kate Otten|Topaz Page-Green|Matthew Parris|Daniella Pellegrini|Sarie Magdalena Perold|Joyce Piliso-Seroke|Vella Pillay|Martin Pistorius|Ian Player|Marius Pope|Fransjohan Pretorius|Percy Qoboza|Raymond Rahme|Goolam Rajah|Rashid Vally|Kevin Richardson (zookeeper)|Kate Robertson (advertising)|Mark Roper|Faanya Rose|Pauline Rose|Leslie Sacks|Stanley Saitowitz|David Sammel|Peter Sarnak|Sonja Schlesin|Vanessa Schulz|Margaret Scott (dancer)|Norman Seeff|Larraine Segil|Jackie Selebi|David Shaffer|Moe Shaik|Mark Shenton|Daniella Shevel|Sibs Shongwe-La Mer|Stefan Simchowitz|Mary Slack|Neal Snyman|Phyllis Spira|Starlet (drag queen)|Jack Suchet|Mervyn Susser|James Suzman|Fred Swaniker|Colin Tatz|George Tilghman|Tokollo 'Magesh' Tshabalala|John Henry Tudhope|David Unterhalter|Faith de Villiers|Raymond Wacks|Rex Wakely Smith|Edward "Terry" Walter Rail Waugh|Tessa Wheeler|Pope Yeatman}}
|
--Grufo (talk) 21:23, 8 September 2025 (UTC)
- Thanks. I created Template:Pagelist/benchmark and Template:Pagelist/sandbox/benchmark with the code you provided, copied four times. I benchmarked your code against the original code and got the results you mentioned. I then removed two somewhat expensive function calls from Module:Pagelist/sandbox and reduced its Lua time usage to 10 ms to 15 ms:
- 1. I removed the call of
mw.title.new()
. That's the expensive call, several dozen ms for the benchmark page. I don't know why it's used, but I think it validates or modifies page titles in some way. mw.title.new() calls php.newTitle() and makeTitleObject(). Both of these might be expensive. - 2. I replaced
mw.ustring.gsub()
by Lua'sstring.gsub()
. Roughly 10 ms faster. If I understand the documentation for mw.ustring.gsub() and ustring patterns correctly, string.gsub() is fine in this case, because we don't use any patterns. - In conclusion: Module:Params is a good deal faster than Module:Pagelist, mostly because it doesn't call mw.title.new().
- On the one hand, I guess that call does something useful. On the other hand, in case it returns nil (which means validation failed, if I understand correctly), we simply use the original page title. So maybe we can simply remove the call of mw.title.new()? I don't know. Maybe @Mr. Stradivarius remembers, although the code is ten years old?
- — Chrisahn (talk) 00:10, 9 September 2025 (UTC)
- @Chrisahn: I have really no idea why
mw.title.new()
is not particularly fast. Module:Params is a generalist module used by many templates, and so over the years I could test and optimize it across different scenarios. I am not sure what exactly makes Module:Pagelist slower, but in any case we are well within the range of what I would call a fine and acceptable speed (we truly exaggerated with those benchmark pages, although on the other hand, using a heavy load was the only way to get meaningful numbers). I wouldn't worry at all about an imperceptibly slower solution. I gave it a try rewriting the template using only Module:Params, because these are the things that make me realize what that module can and cannot do. In general, since it came to life, Module:Params reduced a lot the necessity to create dedicated modules for doing what templates cannot do (take the good old {{Italic title}} template for example, which relies on the non-negligible Module:Italic title, and compare it the newer {{Verbatim title}} template, created using only Module:Params and less than twenty lines of code). This does not mean however that dedicated modules must always be avoided. As long as someone has the time to maintain them, they are perfectly fine. Furthermore Module:Params does have its limitations too. For instance, take the table with the keywordsdot
,pipe
, etc.: since that applies to both|separator=
and|conjunction=
, to reimplement it using Module:Params we would need to repeat the {{switch:}} parser function twice: <includeonly>{{safesubst:<noinclude />#invoke:params| sequential| squeezing| excluding_non-numeric_names| trimming_values| setting|i/l|{{safesubst:<noinclude />P{{safesubst:<noinclude />#switch:{{{separator|}}} | dot = 1 | pipe = 2 | comma = 3 | #default = 4 }}| <b>·</b> | {{safesubst:<noinclude />!}} |, |{{{separator|, }}}}}|{{safesubst:<noinclude />P{{safesubst:<noinclude />#switch:{{{conjunction|}}} | dot = 1 | pipe = 2 | comma = 3 | #default = 4 }}| <b>·</b> | {{safesubst:<noinclude />!}} |, |{{{conjunction| and }}}}}| mapping_by_mixing|{{{delim|}}}{{safesubst:<noinclude />#switch:x{{{nspace|}}} | x | xall = [[$@]] | #default = [[{{{nspace}}}:$@|$@]] }}{{{edelim|{{{delim|}}}}}}| list_values }}</includeonly><noinclude>{{Documentation}}</noinclude>
- Which does not look very nice. We would also need to restore the {{P3}} and {{P4}} templates, which over the years have been deleted (today only {{P1}} and {{P2}} remain). --Grufo (talk) 01:08, 9 September 2025 (UTC)
- Interesting. Why do we need {{Px}} here? Couldn't we just say
dot = <b>·</b>
etc.? — Chrisahn (talk) 09:42, 9 September 2025 (UTC)- The reason is that the {{switch:}} parser function removes leading and trailing spaces. And so if we used it directly we would get X1·X2·X3 … instead of X1 · X2 · X3 … P.S. I just created the {{Px}} template after seeing that {{P3}} and {{P4}} were missing. So when I wrote my previous message the {{Px}} template did not exist yet. --Grufo (talk) 14:12, 9 September 2025 (UTC)
- Would
 <b>·</b> 
work? It seems that {{#switch}} doesn't trim 
. — Chrisahn (talk) 10:24, 13 September 2025 (UTC)- Yes, that would work. It just looks horrible when the template is substituted instead of transcluded. --Grufo (talk) 01:23, 14 September 2025 (UTC)
- Would
- The reason is that the {{switch:}} parser function removes leading and trailing spaces. And so if we used it directly we would get X1·X2·X3 … instead of X1 · X2 · X3 … P.S. I just created the {{Px}} template after seeing that {{P3}} and {{P4}} were missing. So when I wrote my previous message the {{Px}} template did not exist yet. --Grufo (talk) 14:12, 9 September 2025 (UTC)
- Interesting. Why do we need {{Px}} here? Couldn't we just say
- @Chrisahn: I have really no idea why