User:Monkbot/task 18: cosmetic cs1 template cleanup#convert language names to codes

Monkbot task 18 is a WP:COSMETICBOT task to cleanup cs1|2 templates. It is authorized by Wikipedia:Bots/Requests for approval/Monkbot 18.

cs1|2 templates are transcluded in more than [https://templatecount.toolforge.org/index.php?lang=en&namespace=828&name=Citation/CS1 4.7 million pages]. Task 18 is constrained to the canonical list of cs1|2 templates and their more common redirects. Wrapper templates are not considered.

Task 18 does these things:

  1. deletes empty known and unknown named parameters
  2. deletes empty positional parameters
  3. deletes or repairs parameters inside html comments
  4. deletes non-contributing parameter/value pairs
  5. hyphenates cs1|2 parameters when they are written using the to-be-deprecated all-run-together form
  6. converts known language names assigned to {{para|language}} to their MediaWiki codes

This task strives to leave template style as it found it so does not change whitespace in and around template parameters. There is an exception to that whitespace rule: blank lines within vertically formatted cs1|2 templates are removed. Though executed by WP:AWB, this task does not perform AWB general fixes.

Task 18 operates only in mainspace. Any article that has {{tlx|bots|2=deny=monkbot 18}} shall be skipped. Additionally, task 18 maintains a list of articles that it will not edit. Contact the bot's operator to get an article added to the list.

Update 2020-12-15: A modified version of the bot (namespace restriction and empty positional parameter portions disabled) is created for use on templates that wrap the cs1|2 canonical templates. This version will be run manually only in template namespace and is identified as task 18a.

Update 2021-01-10: Because the bot depends on results from mw:Help:CirrusSearch to focus its work, an alternate form of the bot task (18b) has been created that focuses on templates that are not cs1|2 templates but are (in many but not all cases) wrapper templates that use a cs1|2 template. Task 18b runs separately from the main task 18.

delete empty parameters

class="wikitable sortable" style="float:right; margin-left:0.5em"

|+cs1{{pipe}}2 templates with empty parameters (estimate)

parameter || initial count || count || class="unsortable" | search
{{tlx|cite arXiv}}760[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22cite+arxiv%22+insource%3A%2F%5C%7B+%2A%5BCc%5Dite+ar%5BXx%5Div%5B%5E%5C%7D%5D%2A%5C%7C%5B%5E%3D%5D%2B%3D+%2A%5B%5C%7C%5C%7D%5D%2F search]
{{tlx|cite AV media}}{{val|3149|fmt=commas}}1,008[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22cite+AV+media%22+insource%3A%2F%5C%7B+%2A%5BCc%5Dite+%5BAa%5D%5BVv%5D+media%5B%5E%5C%7D%5D%2A%5C%7C%5B%5E%3D%5D%2B%3D+%2A%5B%5C%7C%5C%7D%5D%2F search]
{{tlx|cite AV media notes}}{{val|1845|fmt=commas}}9[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22cite+AV+media+notes%22+insource%3A%2F%5C%7B+%2A%5BCc%5Dite+%5BAa%5D%5BVv%5D+media+notes%5B%5E%5C%7D%5D%2A%5C%7C%5B%5E%3D%5D%2B%3D+%2A%5B%5C%7C%5C%7D%5D%2F search]
{{tlx|cite bioRxiv}}61[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22cite+bioRxiv%22+insource%3A%2F%5C%7B+%2A%5BCc%5Dite+bio%5BRr%5Dxiv%5B%5E%5C%7D%5D%2A%5C%7C%5B%5E%3D%5D%2B%3D+%2A%5B%5C%7C%5C%7D%5D%2F search]
{{tlx|cite book}}{{val|88787|fmt=commas}} (timed out)7,296 (timed out)[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22cite+book%22+insource%3A%2F%5C%7B+%2A%5BCc%5Dite+book%5B%5E%5C%7D%5D%2A%5C%7C%5B%5E%3D%5D%2B%3D+%2A%5B%5C%7C%5C%7D%5D%2F search]
{{tlx|cite citeseerx}}00[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22cite+citeseerx%22+insource%3A%2F%5C%7B+%2A%5BCc%5Dite+citeseerx%5B%5E%5C%7D%5D%2A%5C%7C%5B%5E%3D%5D%2B%3D+%2A%5B%5C%7C%5C%7D%5D%2F search]
{{tlx|cite conference}}{{val|1246|fmt=commas}}11[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22cite+conference%22+insource%3A%2F%5C%7B+%2A%5BCc%5Dite+conference%5B%5E%5C%7D%5D%2A%5C%7C%5B%5E%3D%5D%2B%3D+%2A%5B%5C%7C%5C%7D%5D%2F search]
{{tlx|cite encyclopedia}}{{val|8393|fmt=commas}}4,886[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22cite+encyclopedia%22+insource%3A%2F%5C%7B+%2A%5BCc%5Dite+encyclopedia%5B%5E%5C%7D%5D%2A%5C%7C%5B%5E%3D%5D%2B%3D+%2A%5B%5C%7C%5C%7D%5D%2F search]
{{tlx|cite episode}}{{val|2882|fmt=commas}}297[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22cite+episode%22+insource%3A%2F%5C%7B+%2A%5BCc%5Dite+episode%5B%5E%5C%7D%5D%2A%5C%7C%5B%5E%3D%5D%2B%3D+%2A%5B%5C%7C%5C%7D%5D%2F search]
{{tlx|cite interview}}636191[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22cite+interview%22+insource%3A%2F%5C%7B+%2A%5BCc%5Dite+interview%5B%5E%5C%7D%5D%2A%5C%7C%5B%5E%3D%5D%2B%3D+%2A%5B%5C%7C%5C%7D%5D%2F search]
{{tlx|cite journal}}{{val|111144|fmt=commas}} (timed out)1,177 (timed out)[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22cite+journal%22+insource%3A%2F%5C%7B+%2A%5BCc%5Dite+journal%5B%5E%5C%7D%5D%2A%5C%7C%5B%5E%3D%5D%2B%3D+%2A%5B%5C%7C%5C%7D%5D%2F search]
{{tlx|cite magazine}}{{val|9576|fmt=commas}}113[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22cite+magazine%22+insource%3A%2F%5C%7B+%2A%5BCc%5Dite+magazine%5B%5E%5C%7D%5D%2A%5C%7C%5B%5E%3D%5D%2B%3D+%2A%5B%5C%7C%5C%7D%5D%2F search]
{{tlx|cite mailing list}}300[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22cite+mailing+list%22+insource%3A%2F%5C%7B+%2A%5BCc%5Dite+mailing+list%5B%5E%5C%7D%5D%2A%5C%7C%5B%5E%3D%5D%2B%3D+%2A%5B%5C%7C%5C%7D%5D%2F search]
{{tlx|cite map}}{{val|2620|fmt=commas}}1,835[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22cite+map%22+insource%3A%2F%5C%7B+%2A%5BCc%5Dite+map%5B%5E%5C%7D%5D%2A%5C%7C%5B%5E%3D%5D%2B%3D+%2A%5B%5C%7C%5C%7D%5D%2F search]
{{tlx|cite news}}{{val|69918|fmt=commas}} (timed out)569 (timed out)[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22cite+news%22+insource%3A%2F%5C%7B+%2A%5BCc%5Dite+news%5B%5E%5C%7D%5D%2A%5C%7C%5B%5E%3D%5D%2B%3D+%2A%5B%5C%7C%5C%7D%5D%2F search]
{{tlx|cite newsgroup}}410[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22cite+newsgroup%22+insource%3A%2F%5C%7B+%2A%5BCc%5Dite+newsgroup%5B%5E%5C%7D%5D%2A%5C%7C%5B%5E%3D%5D%2B%3D+%2A%5B%5C%7C%5C%7D%5D%2F search]
{{tlx|cite podcast}}28715[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22cite+podcast%22+insource%3A%2F%5C%7B+%2A%5BCc%5Dite+podcast%5B%5E%5C%7D%5D%2A%5C%7C%5B%5E%3D%5D%2B%3D+%2A%5B%5C%7C%5C%7D%5D%2F search]
{{tlx|cite press release}}{{val|2246|fmt=commas}}37[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22cite+press+release%22+insource%3A%2F%5C%7B+%2A%5BCc%5Dite+press+release%5B%5E%5C%7D%5D%2A%5C%7C%5B%5E%3D%5D%2B%3D+%2A%5B%5C%7C%5C%7D%5D%2F search]
{{tlx|cite report}}{{val|2325|fmt=commas}}79[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22cite+report%22+insource%3A%2F%5C%7B+%2A%5BCc%5Dite+report%5B%5E%5C%7D%5D%2A%5C%7C%5B%5E%3D%5D%2B%3D+%2A%5B%5C%7C%5C%7D%5D%2F search]
{{tlx|cite serial}}540[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22cite+serial%22+insource%3A%2F%5C%7B+%2A%5BCc%5Dite+serial%5B%5E%5C%7D%5D%2A%5C%7C%5B%5E%3D%5D%2B%3D+%2A%5B%5C%7C%5C%7D%5D%2F search]
{{tlx|cite sign}}1113[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22cite+sign%22+insource%3A%2F%5C%7B+%2A%5BCc%5Dite+sign%5B%5E%5C%7D%5D%2A%5C%7C%5B%5E%3D%5D%2B%3D+%2A%5B%5C%7C%5C%7D%5D%2F search]
{{tlx|cite speech}}1012[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22cite+speech%22+insource%3A%2F%5C%7B+%2A%5BCc%5Dite+speech%5B%5E%5C%7D%5D%2A%5C%7C%5B%5E%3D%5D%2B%3D+%2A%5B%5C%7C%5C%7D%5D%2F search]
{{tlx|cite ssrn}}00[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22cite+ssrn%22+insource%3A%2F%5C%7B+%2A%5BCc%5Dite+ssrn%5B%5E%5C%7D%5D%2A%5C%7C%5B%5E%3D%5D%2B%3D+%2A%5B%5C%7C%5C%7D%5D%2F search]
{{tlx|cite techreport}}570[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22cite+techreport%22+insource%3A%2F%5C%7B+%2A%5BCc%5Dite+techreport%5B%5E%5C%7D%5D%2A%5C%7C%5B%5E%3D%5D%2B%3D+%2A%5B%5C%7C%5C%7D%5D%2F search]
{{tlx|cite thesis}}{{val|2354|fmt=commas}}93[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22cite+thesis%22+insource%3A%2F%5C%7B+%2A%5BCc%5Dite+thesis%5B%5E%5C%7D%5D%2A%5C%7C%5B%5E%3D%5D%2B%3D+%2A%5B%5C%7C%5C%7D%5D%2F search]
{{tlx|cite web}}{{val|148445|fmt=commas}} (timed out)72,171 (timed out)[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22cite+web%22+insource%3A%2F%5C%7B+%2A%5BCc%5Dite+web%5B%5E%5C%7D%5D%2A%5C%7C%5B%5E%3D%5D%2B%3D+%2A%5B%5C%7C%5C%7D%5D%2F search]
{{tlx|citation}}{{val|21644|fmt=commas}}545 (timed out)[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22citation%22+insource%3A%2F%5C%7B+%2A%5BCc%5Ditation%5B%5E%5C%7D%5D%2A%5C%7C%5B%5E%3D%5D%2B%3D+%2A%5B%5C%7C%5C%7D%5D%2F search]
rowspan="2" | totals{{val|477973|fmt=commas}}90,338rowspan="2" |  
2020-11-132021-02-03

It is to be expected that some significant portion of cs1|2 transclusions will hold some number of superfluous parameters. One purpose of this task to remove those superfluous parameters. Empty parameters in cs1|2 templates occur for various reasons: the parameter is no longer required or not required in 'this' citation; a skeleton template was copied from a template documentation page and only partially filled in; deprecated error messages were 'fixed' by removing the parameter's value; the template was reworked; the template was placed by automated or semiautomated tools that inserted empty parameters; there are, no doubt, other explanations. For cs1|2, empty parameters serve no purpose.

Editors commonly complain that inline references make it more difficult to read wikitext. Empty parameters in cs1|2 templates occupy space for no meaningful purpose and, as a consequence, contribute to the wikitext readability problem.

The table lists all of the cs1|2 templates. The second column states the approximate number of mainspace articles using the template where at least one parameter was empty. The counts were last updated on the date listed at the bottom of the table.

delete empty positional parameters

cs1|2 does not support positional (unnamed) parameters. A positional parameter is one that does not contain an assignment operator (=). Positional parameters that contain nothing or only whitespace, have two forms:

:||

:|}}

Task 18 deletes the first pipe and any whitespace that exists between it and the succeeding pipe or brace.

Task 18 ignores positional parameters that have content other than whitespace because cs1|2 emits a reader-facing text ignored error message for those sorts of positional parameters.

delete empty named parameters in html comments

To cs1|2, parameters that are hidden with html comment markup ({{tag|!--|content={{var|content}}}}) can appear to be empty positional parameters because MediaWiki removes html comments and their content before handing the template to Module:Citation/CS1. cs1|2 templates entirely within html markup are ignored.

Empty parameters that have this form are deleted along with the html comment markup:

:|<!-- param= -->

Similarly, empty parameters inside html comment markup are deleted; parameters with assigned values are retained:

:<!-- |param={{var|value}} |param= --><!-- |param={{var|value}} -->

repair parameters in html comments

To cs1|2, parameters that are hidden with html comment markup ({{tag|!--|content={{var|content}}}}) can appear to be empty positional parameters because MediaWiki removes html comments and their content before handing the template to Module:Citation/CS1. cs1|2 templates entirely within html markup are ignored.

Parameters that have this form are repaired by moving the preceding pipe into the html comment markup:

:|<!-- param={{var|value}} --><!-- |param={{var|value}} -->

A similar configuration is commonly found. This form may or may not look like an empty positional parameter to cs1|2 depending on the surrounding wikimarkup. This form is repaired for the purposes of consistency:

:|<!-- param={{var|value}} |--><!-- |param={{var|value}} --> |

Comments that do not have an assignment operator (=) but which occupy all of the space between a pair of pipes or a pipe and the template's closing brace are repaired by moving the leading pipe inside the html comment:

:|<!-- plain text html comment --> |<!-- |plain text html comment --> |

delete non-contributing parameters

There are several parameters and specific parameter/value pairs that, under certain conditions, to not contribute the rendering of the template. Task 18 deletes these:

  • {{anchor|deadurl}}{{para|deadurl}} – is routinely added (with the assigned value y) to cs1|2 templates created by the unmaintained tool ReFill. Because {{para|deadurl}} is no-longer supported by cs1|2, when it is present in cs1|2 templates, cs1|2 emits the error message: {{error-small|Unknown parameter {{para|deadurl|plain=yes}} ignored ({{para|url-status|plain=yes}} suggested)}} and adds the article to {{cl|Pages with citations using unsupported parameters}} which gnomes keep mostly empty. When task 18 encounters {{para|deadurl|y}} (or the similar {{para|deadurl|yes}} and {{para|deadurl|true}} and their hyphenated forms), the parameter shall be deleted. Replacement is not necessary because {{para|deadurl|y}} (when it was supported) was redundant to the cs1|2 default state. See {{para|url-status}} documentation.
  • {{anchor|mode}}{{para|mode}} – this parameter accepts one of two keywords: cs1 or cs2. The purpose is to direct the template to render in the specified style. For example, {{tlx|citation}} is a native cs2 template. {{tnull|citation}} will render as if it were a cs1 template when given {{para|mode|cs1}}; similarly, cs1 templates render in cs2 style when given {{para|mode|cs2}}. Setting {{para|mode}} to the template's native style does not change the rendering. Task 18 deletes {{para|mode}} parameters when they match the template's native style. See {{para|mode}} documentation.
  • {{anchor|nlsytle}}{{para|name-list-style}} – controls how name lists are rendered. When assigned one of the values amp, ampersand, and, &, or serial, cs1|2 inserts an ampersand or the word 'and' between the last two names of a name list. When none of the name lists have two or more names, the parameter does not change the rendering. When assigned the value vanc, name lists are rendered in Vancouver style. {{para|name-list-style|vanc}} requires {{para|last}} and {{para|first}} (or aliases); without {{para|first}} aliases, the parameter does not change the rendering. See {{para|name-list-style}} documentation.
  • {{anchor|nllink}}{{para|<{{var|name-list}}>-link}}, {{anchor|nlmask}}{{para|<{{var|name-list}}>-mask}}{{anchor|fn_a_blink}}[a] – these wikilink or mask a <{{var|name}}> in an associated <{{var|name-list}}>. When there is no associated {{para|<{{var|name}}>}} (for example, {{para|author-mask14|2}} but no {{para|author14}}), these parameters do not change the rendering.
  • {{anchor|nopp}}{{para|no-pp}} – suppresses p. and pp. page annotation when either of {{para|page}} or {{para|pages}} has a value; when there is no {{para|page}} or {{para|pages}} parameter, this parameter does not change the rendering. When found in {{tlx|citation}} templates where {{para|journal}} has an assigned value or when found in {{tlx|cite journal}}, {{para|no-pp}} has no value because pagination in journal citations does not use the P. and pp. annotation.
  • {{anchor|origyear}}{{para|orig-year}} – a free-form parameter that accompanies {{para|year}}, {{para|date}} or when neither of those are present, {{para|publication-date}}. When none of those are present, {{para|orig-year}} is not rendered.
  • {{anchor|postscript}}{{para|postscript}} – specifies the rendered template's terminal punctuation. Default terminal punctuation for cs1 is a dot; for cs2, terminal punctuation is omitted. {{para|postscript|.}} in cs1 templates and {{para|postscript|none}} in cs2 templates does not change the rendering. The form {{para|postscript|<!--none-->}} is ignored by cs1|2 templates because the html comments make {{para|postscript}} an empty parameter.
  • {{anchor|refharv}}{{para|ref|harv}} – At the 2020-04-18 update to Module:Citation/CS1 ({{diff|Module:Citation/CS1|prev|951705319|this edit}}), {{para|ref|harv}} was internally defined as the default state so the explicit {{para|ref|harv}} does not change the template's function. Use of this parameter/value pair is tracked in {{cl|1=CS1 maint: ref=harv‎}}. See {{para|ref}} documentation.
  • {{anchor|urlstatus}}{{para|url-status}} – like its predecessors {{para|dead-url}} and {{para|deadurl}}, {{para|url-status}} is a display control parameter that determines how a cs1|2 template will be rendered when that template has {{para|archive-url}} and {{para|archive-date}}. When {{para|archive-url}} and {{para|archive-date}} are empty or omitted, {{para|url-status}} is non-functional. See {{para|url-status}} documentation.

hyphenate cs1|2 parameter names

class="wikitable sortable" style="float:right; margin-left:0.5em"

|+cs1{{pipe}}2 parameters to be hyphenated

parameter || initial count || count || class="unsortable" | search
{{para|accessdate}}2,804,8811,841,029[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22Module%3ACitation%2FCS1%22+insource%3Aaccessdate search]
{{para|archivedate}}837,655444,873[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22Module%3ACitation%2FCS1%22+insource%3Aarchivedate search]
{{para|archiveurl}}834,802444,601[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22Module%3ACitation%2FCS1%22+insource%3Aarchiveurl search]
{{para|authorlink}}268,23285,737[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22Module%3ACitation%2FCS1%22+insource%3Aauthorlink search]
{{para|authormask}}40[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22Module%3ACitation%2FCS1%22+insource%3Aauthormask search]
{{para|booktitle}}3,34528[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22Module%3ACitation%2FCS1%22+insource%3Abooktitle search]
{{para|chapterurl}}17,289250[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22Module%3ACitation%2FCS1%22+insource%3Achapterurl search]
{{para|conferenceurl}}{{dagger}}4270[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22Module%3ACitation%2FCS1%22+insource%3Aconferenceurl search]
{{para|contributionurl}}{{dagger}}400[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22Module%3ACitation%2FCS1%22+insource%3Acontributionurl search]
{{para|displayauthors}}11[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22Module%3ACitation%2FCS1%22+insource%3Adisplayauthors search]
{{para|editorlink}}10[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22Module%3ACitation%2FCS1%22+insource%3Aeditorlink search]
{{para|editormask}}10[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22Module%3ACitation%2FCS1%22+insource%3Aeditormask search]
{{para|episodelink}}2,5392[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22Module%3ACitation%2FCS1%22+insource%3Aepisodelink search]
{{para|laydate}}{{dagger}}1,04913[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22Module%3ACitation%2FCS1%22+insource%3Alaydate search]
{{para|laysource}}{{dagger}}1,09113[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22Module%3ACitation%2FCS1%22+insource%3Alaysource search]
{{para|layurl}}{{dagger}}5382[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22Module%3ACitation%2FCS1%22+insource%3Alayurl search]
{{para|mailinglist}}37976[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22Module%3ACitation%2FCS1%22+insource%3Amailinglist search]
{{para|mapurl}}8131[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22Module%3ACitation%2FCS1%22+insource%3Amapurl search]
{{para|nopp}}2,90235[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22Module%3ACitation%2FCS1%22+insource%3Anopp search]
{{para|notracking}}11[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22Module%3ACitation%2FCS1%22+insource%3Anotracking search]
{{para|origyear}}44,0229,841[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22Module%3ACitation%2FCS1%22+insource%3Aorigyear search]
{{para|publicationdate}}54275[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22Module%3ACitation%2FCS1%22+insource%3Apublicationdate search]
{{para|publicationplace}}1890[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22Module%3ACitation%2FCS1%22+insource%3Apublicationplace search]
{{para|sectionurl}}{{dagger}}654[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22Module%3ACitation%2FCS1%22+insource%3Asectionurl search]
{{para|serieslink}}5,0428[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22Module%3ACitation%2FCS1%22+insource%3Aserieslink search]
{{para|seriesno}}{{dagger}}1,07513[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22Module%3ACitation%2FCS1%22+insource%3Aseriesno search]
{{para|subjectlink}}00[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22Module%3ACitation%2FCS1%22+insource%3Asubjectlink search]
{{para|timecaption}}{{dagger}}390[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22Module%3ACitation%2FCS1%22+insource%3Atimecaption search]
{{para|titlelink}}{{dagger}}3,51893[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22Module%3ACitation%2FCS1%22+insource%3Atitlelink search]
{{para|transcripturl}}9101[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22Module%3ACitation%2FCS1%22+insource%3Atranscripturl search]
{{para|author[0-9]+link}}648 (timed out)126 (timed out)[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22Module%3ACitation%2FCS1%22+insource%3A%2Fauthor%5B0-9%5D%2Blink%2F search]
{{para|author[0-9]+mask}}0 (timed out)0 (timed out)[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22Module%3ACitation%2FCS1%22+insource%3A%2Fauthor%5B0-9%5D%2Bmask%2F search]
{{para|editor[0-9]+link}}20 (timed out)0 (timed out)[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22Module%3ACitation%2FCS1%22+insource%3A%2Feditor%5B0-9%5D%2Blink%2F search]
{{para|editor[0-9]+mask}}0 (timed out)0 (timed out)[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22Module%3ACitation%2FCS1%22+insource%3A%2Feditor%5B0-9%5D%2Bmask%2F search]
{{para|subject[0-9]+link}}0 (timed out)0 (timed out)[https://en.wikipedia.org/w/index.php?search=hastemplate%3A%22Module%3ACitation%2FCS1%22+insource%3A%2Fsubject%5B0-9%5D%2Blink%2F search]
rowspan="2" | totals4,831,3282,826,853rowspan="2" |  
2020-11-13 || 2021-02-03
colspan="4" | {{dagger}} currently deprecated
support withdrawn for parameters that are struckout

Because cs1|2 is an amalgam of several individually developed templates, it acquired a variety of parameter-name styles: {{para|lowercase}}, {{para|Capitalized}}, {{para|camelCase}}, {{para|underscore_separated}}, {{para|space separated}}, {{para|hyphen-separated}}, {{para|allruntogether}}. The {{para|Capitalized}}, {{para|camelCase}}, {{para|underscore_separated}}, and {{para|space separated}} parameter name styles have all been deprecated and support for these styles withdrawn in favor of the {{para|lowercase}} and {{para|hyphen-separated}} forms as a result of this RfC. For parameter names that are multiword, cs1|2 is gradually shifting to prefer the hyphenated form. The table lists the all-run-together form with the approximate number of articles that transclude cs1|2 templates using these parameters. Task 18 replaces the all-run-together forms of these parameters with the hyphenated forms.

The {{para|accessdate}} and {{para|authorlink}} parameter names have been included in awb's genfixes since {{diff|Wikipedia:AutoWikiBrowser/Rename_template_parameters|984829895|983479364|this edit}}. There has been some pushback against using genfixes to normalize cs1|2 parameter name style. See {{slink|Wikipedia_talk:AutoWikiBrowser/Archive_32#Citation_parameter_renaming}}.

There are commonly used tools that continue to insert the all-run-together names. An interface protected edit request has been submitted to normalize all-run-together parameter names emitted by WP:RefToolbar. See {{slink|MediaWiki_talk:RefToolbarConfig.js#normalize_parameter_names}}.

convert language names to codes

As a courtesy to editors at other-language wikis, it is desirable to use the MediaWiki language codes instead of English-language language names in {{para|language}} so that cs1|2 can render language names using the other wiki's language without the need for an editor to make a translation. Task 18 will replace language names with the associated MediaWiki code. See the {{para|language}} documentation and the list of (mostly) English-language language names and associated codes.

edit summary messaging

For each edit made, task 18 creates an edit summary detailing what was done. For example, this edit summary from a test (no save) of Ida B. Wells:

:Task 18 (cosmetic) (dev test): eval 146 templates: del empty params (1251×); hyphenate params (4×); del pos params (1×); del |ref=harv (4×);

Each summary always begins with the 'Task 18 (cosmetic) (dev test): eval {{var|n}} templates:' leader where {{var|n}} is the total number of cs1|2 templates and recognized redirects that task 18 evaluated. The remaining portion of the edit summary is assembled from one or more of these:

:del cmtd params ({{var|n}}×); – deleted commented parameters

:rep cmtd params ({{var|n}}×); – repaired commented parameters

:del empty params ({{var|n}}×); – deleted empty parameters

:hyphenate params ({{var|n}}×); – hyphenated parameter names

:del empty pos params ({{var|n}}×); – deleted empty positional parameters

:del |ref=harv ({{var|n}}×); – deleted {{pipe}}ref=harv

:del |mode= ({{var|n}}×); – deleted {{pipe}}mode=

:del |postscript= ({{var|n}}×); – deleted {{pipe}}postscript=

:del |url-status= ({{var|n}}×); – deleted {{pipe}}url-status=

:del |deadurl= ({{var|n}}×); – deleted {{pipe}}deadurl=

:del |no-pp= ({{var|n}}×); – deleted {{pipe}}no-pp=

:del |orig-year= ({{var|n}}×); – deleted {{pipe}}orig-year

:del |name-list-style= ({{var|n}}×); – deleted {{pipe}}name-list-style=

:del |<name-list>-mask= ({{var|n}}×); – deleted {{pipe}}<name-list>-mask=

:del |<name-list>-link= ({{var|n}}×); – deleted {{pipe}}<name-list>-link=

:cvt lang vals ({{var|n}}×); – converted language values

:skip ({{var|n}}×); – during development of task 18, it found malformed cs1|2 templates that contain the opening

or closing
that belongs to wikitables. An example of this is found in {{oldid|Satish_Shah|983028544|this version of Satish Shah}} which is missing the closing }} for {{oldid|Satish_Shah|983028544#cite_ref-toi_4-3|this reference}}. Left unchecked, task 18 will see the table content as part of that broken {{tlx|cite news}} template and delete many of the double pipe markup used to separate cells in the wikitable. This particular garbage is detected and skipped but editors are endlessly clever when it comes to breaking cs1|2 templates.

AWB truncates long edit summaries (:phab:T199347) so the messaging is necessarily terse in an attempt to list everything accomplished by task 18 in the summary. When that is not possible, task 18 truncates its summary and adds an ellipsis.

known issues

When an article transcludes a named reference that exactly matches a named reference in the article, and task 18 edits the article's named reference, MediaWiki will emit this error message:

:The named reference "$1" was defined multiple times with different content (help page).

Task 18 cannot know that a cs1|2 template that it edits is mirrored in a transcluded template. If you know of articles where this is a problem, give a list of those articles to the bot's operator so that the bot can be instructed to skip those articles.

notes

:a. {{anchor|fn_a}}^ The {{para|<{{var|name-list}}>-link}} and {{para|<{{var|name-list}}>-mask}} parameters are:

{{col-float}}

  • {{para|author-link}}
  • {{para|author{{var|n}}-link}}
  • {{para|author-link{{var|n}}}}
  • {{para|contributor-link}}
  • {{para|contributor{{var|n}}-link}}
  • {{para|contributor-link{{var|n}}}}
  • {{para|editor-link}}
  • {{para|editor{{var|n}}-link}}
  • {{para|editor-link{{var|n}}}}
  • {{para|interviewer-link}}
  • {{para|interviewer{{var|n}}-link}}
  • {{para|interviewer-link{{var|n}}}}
  • {{para|translator-link}}
  • {{para|translator{{var|n}}-link}}
  • {{para|translator-link{{var|n}}}}

{{col-float-break}}

  • {{para|author-mask}}
  • {{para|author{{var|n}}-mask}}
  • {{para|author-mask{{var|n}}}}
  • {{para|contributor-mask}}
  • {{para|contributor{{var|n}}-mask}}
  • {{para|contributor-mask{{var|n}}}}
  • {{para|editor-mask}}
  • {{para|editor{{var|n}}-mask}}
  • {{para|editor-mask{{var|n}}}}
  • {{para|interviewer-mask}}
  • {{para|interviewer{{var|n}}-mask}}
  • {{para|interviewer-mask{{var|n}}}}
  • {{para|translator-mask}}
  • {{para|translator{{var|n}}-mask}}
  • {{para|translator-mask{{var|n}}}}

{{col-float-end}}

script

// This script does cosmetic work:

// repairs / removes commented parameters

// deletes empty parameters

// replaces un-hyphenated parameters with their hyphenated forms

// deletes |ref=harv

// replaces language names in |language= with their MediaWiki ISO 639-like codes

//

// wikitext searches:

// html comments:

// hastemplate:"Module:Citation/CS1" insource:/\{ *[Cc]it[ae][^\}]*\| *\]+\-\-+\>/

// mode:

// hastemplate:Citation insource:/\{ *[Cc]itation[^\}]*\| *mode *= *cs2/

// hastemplate:"Module:Citation/CS1" insource:/\{ *[Cc]ite[^\}]*\| *mode *= *cs1/

// deadurl:

// hastemplate:"Module:Citation/CS1" insource:"deadurl"

// postscript:

// hastemplate:Citation insource:/\{ *[Cc]itation[^\}]*\| *postscript *= *none/

// hastemplate:"Module:Citation/CS1" insource:/\{ *[Cc]ite[^\}]*\| *postscript *= *\./

// hastemplate:"Module:Citation/CS1" insource:/\{ *[Cc]it[ae][^\}]*\| *postscript *= *\

//

// category:

// CS1 errors: empty unknown parameters‎

//

public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip)

{

if (0 != wikiNamespace ) // if is not mainspace

{

if (-1 == ArticleTitle.IndexOf ("User:Trappist the monk")) // don't skip pages in my own user space

{

Skip = true;

Summary = @"article not in mainspace: " + wikiNamespace;

return ArticleText; // abandon this edit

}

}

if (skip_map.ContainsKey (ArticleTitle)) // if is in the skip list

{

Skip = true;

Summary = @"article in skip list";

return ArticleText; // abandon this edit

}

Skip = false; // assume that something will be changed

// Summary = "Task 18 (cosmetic) (dev test):"; // uses redirect to User:Monkbot/task 18: cosmetic cs1 template cleanup

// Summary = "Task 18 (cosmetic) (BRFA trial):";

Summary = "Task 18 (cosmetic):";

int total_count = 0; // total number of cs1|2 templates

int skip_count = 0; // skip count incremented when cite template holds wikitable markup

int comment_deleted = 0;

int comment_repaired = 0;

int empty_positional_deleted = 0;

int params_removed_count = 0;

int params_hyphenated_count = 0;

int ref_harv_count = 0;

int url_status_count =0;

int deadurl_count = 0;

int nopp_count = 0;

int orig_count = 0;

int mode_count = 0;

int ps_count = 0;

int nls_count = 0;

int mask_count = 0;

int link_count = 0;

int language_count = 0;

//---------------------------< B E G I N >--------------------------------------------------------------------

ArticleText = hide (ArticleText, IS_CS1); // hide all templates except cs1|2 and hide wikilinks

//---------------------------< M A I N >----------------------------------------------------------------------

//

// this is main

//

if (Regex.Match (ArticleText, template_pattern).Success)

ArticleText = Regex.Replace (ArticleText, template_pattern,

delegate(Match match)

{

string template = match.Groups[0].Value; // this will be returned if no changes

if ((-1 != template.IndexOf("__0T4BL3__")) || (-1 != template.IndexOf("__CT4BL3__"))) // if table markup found in the cite template abandon

{

skip_count++;

return template;

}

total_count++; // bump total number of cs1|2 templates tally

template = counted_replace (template, comment_params_1_pattern, "$2$1$3$5$4", ref comment_repaired); // | to |

template = counted_replace (template, comment_params_2_pattern, "$2$1$3", ref comment_repaired); // | to

template = counted_replace (template, comment_params_3_pattern, "", ref params_removed_count); // | to (delete)

template = counted_replace (template, comment_params_4_pattern, "$1", ref params_removed_count); // to

template = counted_replace (template, comment_params_5_pattern, "$2$1$3", ref comment_repaired); // | to

template = counted_replace (template, empty_positional_parameter_nl, "$1", ref empty_positional_deleted); // || or |} to | or } (newline variant)

template = counted_replace (template, empty_positional_parameter, "$1", ref empty_positional_deleted); // || or |} to | or }

template = counted_replace (template, ref_harv_pattern, "", ref ref_harv_count); // |ref=harv to (delete)

template = mode_remove (template, ref mode_count);

template = postscript_remove (template, ref ps_count);

template = empty_param_remove (template, ref params_removed_count); // this is a prerequisite function for these:

template = url_status_remove (template, ref url_status_count, ref deadurl_count);

template = hyphenate (hyphenate_map, template, ref params_hyphenated_count); // this is a prerequisite function for these:

template = nopp_remove (template, ref nopp_count);

template = orig_year_remove (template, ref orig_count);

template = name_list_style_remove (template, ref nls_count);

template = name_link_mask_remove (template, ref mask_count, @"mask");

template = name_link_mask_remove (template, ref link_count, @"link");

template = language (language_map, template, ref language_count);

while (Regex.Match (template, empty_comment_pattern).Success) // cleanup; delete (empty or only whitespace)

template = Regex.Replace (template, empty_comment_pattern, "");

return template;

});

//---------------------------< F I N I S H >------------------------------------------------------------------

ArticleText = unhide (ArticleText); // unhide all that is hidden

if (0 != total_count) // build our edit summary

{

Summary = summary_concat (Summary, " eval " + total_count + " template" + (1 == total_count ? ":" : "s:"));

if (0 != comment_deleted)

Summary = summary_concat (Summary, " del cmtd params (" + comment_deleted + "×);");

if (0 != comment_repaired)

Summary = summary_concat (Summary, " rep cmtd params (" + comment_repaired + "×);");

if (0 != params_removed_count)

Summary = summary_concat (Summary, " del empty params (" + params_removed_count + "×);");

if (0 != params_hyphenated_count)

Summary = summary_concat (Summary, " hyphenate params (" + params_hyphenated_count + "×);");

if (0 != empty_positional_deleted)

Summary = summary_concat (Summary, " del pos params (" + empty_positional_deleted + "×);");

if (0 != ref_harv_count)

Summary = summary_concat (Summary, " del |ref=harv (" + ref_harv_count + "×);");

if (0 != mode_count)

Summary = summary_concat (Summary, " del |mode= (" + mode_count + "×);");

if (0 != ps_count)

Summary = summary_concat (Summary, " del |postscript= (" + ps_count + "×);");

if (0 != url_status_count)

Summary = summary_concat (Summary, " del |url-status= (" + url_status_count + "×);");

if (0 != deadurl_count)

Summary = summary_concat (Summary, " del |deadurl= (" + deadurl_count + "×);");

if (0 != nopp_count)

Summary = summary_concat (Summary, " del |no-pp= (" + nopp_count + "×);");

if (0 != orig_count)

Summary = summary_concat (Summary, " del |orig-year= (" + orig_count + "×);");

if (0 != nls_count)

Summary = summary_concat (Summary, " del |name-list-style= (" + nls_count + "×);");

if (0 != mask_count)

Summary = summary_concat (Summary, " del |-mask= (" + mask_count + "×);");

if (0 != link_count)

Summary = summary_concat (Summary, " del |-link= (" + link_count + "×);");

if (0 != language_count)

Summary = summary_concat (Summary, " cvt lang vals (" + language_count + "×);");

if (0 != skip_count)

Summary = summary_concat (Summary, " skip (" + skip_count + "×);");

}

else

{

Skip = true;

Summary = Summary + " no templates to evaluate;";

}

System.IO.StreamWriter sw;

string log_file = @"Z:\Wikipedia\AWB\Monkbot_tasks\Task18_" + DateTimeOffset.Now.ToString("u").Substring (0, 10) + @".csv";

if (!System.IO.File.Exists (log_file))

{ // for csv import, pipe is string delimiter here because not legal wp title char

sw = System.IO.File.AppendText (log_file);

sw.WriteLine ("|Article|, |evaluated|, |deleted comment|, |repaired comment|, |empty params|, |hyphenated|, |empty pos params|, |ref=harv|, |mode|, |postscript|, "

+ "|url-status|, |deadurl|, |no-pp|, |orig-year|, |name-list-style|, |-mask|, |-link|, |language|, |skipped|");

sw.Close();

}

if (Skip)

{

sw = System.IO.File.AppendText (log_file);

sw.WriteLine ("|" + ArticleTitle + "|," + total_count);

sw.Close();

}

else

{

sw = System.IO.File.AppendText (log_file);

sw.WriteLine ("|" + ArticleTitle + "|," + total_count + "," + comment_deleted + "," + comment_repaired + "," + params_removed_count + "," + params_hyphenated_count

+ "," + empty_positional_deleted + "," + ref_harv_count + "," + mode_count + "," + ps_count + "," + url_status_count + "," + deadurl_count

+ "," + nopp_count + "," + orig_count + "," + nls_count + "," + mask_count + "," + link_count + "," + language_count + "," + skip_count);

sw.Close();

}

return ArticleText;

}

//===========================<< S U P P O R T >>==============================================================

//---------------------------< H I D E >----------------------------------------------------------------------

//

// HIDE TEMPLATES: find templates that are not ; replace the opening {{ with __0P3N__, the closing }}

// with __CL0S3__, and internal | (pipes) with __P1P3__

//

// single curly braces in urls and other parameter values can confuse other regex in this code so replace {

// with __0CU!21Y__ and } with __CCU!21Y__

//

private string hide (string ArticleText, string dont_hide)

{

string pattern = @"\{\{(?!\s*" + dont_hide + @")[^\{\}]*\}\}";

if (Regex.Match (ArticleText, pattern).Success)

{

ArticleText = Regex.Replace(ArticleText, pattern,

delegate(Match match)

{

string fixed_template; // a hidden template is assembled here

string raw_template = match.Groups[0].Value; // the whole template

pattern = @"\{\{"; // hide the opening {{

fixed_template = Regex.Replace (raw_template, pattern, "__0P3N__");

pattern = @"\}\}"; // hide the closing }}

fixed_template = Regex.Replace (fixed_template, pattern, "__CL0S3__");

pattern = @"\|"; // and hide the pipes

fixed_template = Regex.Replace (fixed_template, pattern, "__P1P3__");

return fixed_template;

});

}

pattern = @"(\\|\}]*)\{\{(\s*" + dont_hide + @"[^\}]*)\}\}([^\>]*\-{2,}\>)"; //

ArticleText = Regex.Replace(ArticleText, pattern, "$1__0P3N__$2__CL0S3__$3");

pattern = @"\{\|"; // open table markup

ArticleText = Regex.Replace(ArticleText, pattern, "__0T4BL3__");

pattern = @"\|\}(?!\})"; // open table markup

ArticleText = Regex.Replace(ArticleText, pattern, "__CT4BL3__");

pattern = @"([^\{])\{([^\{])"; // single opening curly brace

ArticleText = Regex.Replace(ArticleText, pattern, "$1__0CU!21Y__$2");

pattern = @"([^\}])\}([^\}])"; // single closing curly brace

ArticleText = Regex.Replace(ArticleText, pattern, "$1__CCU!21Y__$2");

pattern = @"\[\[(?![Ff]ile|[Ii]mage)([^\|\]]+)\|([^\]]+)\]\]"; // HIDE complex wikilinks: label to __WL1NK_O__article title__P1P3__label__WL1NK_C__

ArticleText = Regex.Replace(ArticleText, pattern, "__WL1NK_O__$1__P1P3__$2__WL1NK_C__"); // [[File: with wikilinks inside can be confusing

pattern = @"\[\[([^\]]+)\]\]"; // HIDE simple wikilinks: article title to __WL1NK_O__article title__WL1NK_C__

ArticleText = Regex.Replace(ArticleText, pattern, "__WL1NK_O__$1__WL1NK_C__");

return ArticleText;

}

//---------------------------< U N H I D E >------------------------------------------------------------------

//

// UNHIDE TEMPLATES: find templates and wikilinks that are hidden; replace the 'hide' keywords with the

// appropriate wiki markup

//

private string unhide (string ArticleText)

{

ArticleText = Regex.Replace(ArticleText, @"__WL1NK_O__", "[["); // UNHIDE: replace __WL1NK_O__ with [[

ArticleText = Regex.Replace(ArticleText, @"__WL1NK_C__", "]]"); // UNHIDE: replace __WL1NK_C__ with ]]

ArticleText = Regex.Replace(ArticleText, @"__P1P3__", "|"); // UNHIDE: replace __P1P3__ with |

ArticleText = Regex.Replace(ArticleText, @"__0T4BL3__", "

"); // UNHIDE: replace __0T4BL3__ with {|

ArticleText = Regex.Replace(ArticleText, @"__CT4BL3__", "

"); // UNHIDE: replace __CT4BL3__ with |}

ArticleText = Regex.Replace(ArticleText, @"__0CU!21Y__", "{"); // UNHIDE: replace __0CU!21Y__ with {

ArticleText = Regex.Replace(ArticleText, @"__CCU!21Y__", "}"); // UNHIDE: replace __CCU!21Y__ with }

ArticleText = Regex.Replace(ArticleText, @"__0P3N__", "{{"); // UNHIDE: replace __0P3N__ with {{

ArticleText = Regex.Replace(ArticleText, @"__CL0S3__", "}}"); // UNHIDE: replace __CL0S3__ with }}

return ArticleText;

}

//---------------------------< S U M M A R Y _ C O N C A T >--------------------------------------------------

//

// concatenates text onto an existing edit summary string, limiting the string to a length of no more than 247

// characters. When

appended with would be longer than the allowed 247 character limit, this

// function replaces with an ellipsis. Once an ellipsis is added, no more can be added to

//

private string summary_concat (string summary, string text)

{

if (0 <= summary.IndexOf ("...")) // if ellipsis already present in

, abandon

return summary;

if (247 >= (summary.Length + text.Length + 3)) // if adding to summary will overrun the 247 char limit (+ 3 to make sure we can add ellipsis if necessary)

return summary + text; // append to

and done

return summary + "..."; // append ellipsis instead

}

//---------------------------< C O U N T E D _ R E P L A C E >------------------------------------------------

//

// common function to replace with and bump until no more

//

private string counted_replace (string template, string pattern, string replace, ref int count)

{

Regex rgx = new Regex (pattern); // make a new regex from

while (Regex.Match (template, pattern).Success) // look for in