User:Monkbot/Task 2: CS1 deprecated coauthor parameters
This script is intended to pluck some of the low hanging fruit from {{cl|Pages containing cite templates with deprecated parameters}}. Editors often place multiple coauthors in either {{para|coauthor}} or {{para|coauthors}} (these two parameters are aliases of each other so hereafter {{para|coauthor}}) and separate the coauthors with a semicolon with or without a following space. This script replaces {{para|coauthor}} with an appropriate number of {{para|authorn}} parameters beginning with {{para|author2}}.
The script will not do a replacement when:
- the template contains {{para|ref|harv}}. {{para|coauthor}} is not used when Module:Citation/CS1 creates the
CITEREF
(used by {{tlx|sfn}} and the {{tlx|harv}} family of templates) but {{para|author2}}, {{para|author3}}, and {{para|author4}} are used. - the template is a {{tlx|citation}} template because this template automatically sets {{para|ref|harv}}.
- the template contains {{para|lastn}} or {{para|authorn}} where n is greater than 1 and when:
- {{para|lastn}} or {{para|authorn}} contains a value and precedes {{para|coauthor}} – if a stray {{para|author2}} is empty and precedes {{para|coauthor}} the replacement {{para|author2}} value overrides the empty {{para|author2}}; or
- {{para|lastn}} or {{para|authorn}} with or without an assigned value follows {{para|coauthor}} – a {{para|author2}} that follows the replacement {{para|author2}} will override the replacement
When {{para|coauthor}} in CS1 citations have only one coauthor name, or a list of names separated by semicolons, replace {{para|coauthor}} and subsequent semicolons with {{para|author2}}, {{para|author3}}, etc. When {{para|coauthor}} is empty, remove it from the citation. For example replace:
:{{para|coauthor|First Coauthor; Second Coauthor; Third Coauthor}}
with
:{{para|author2|First Coauthor}}{{para|author3|Second Coauthor}}{{para|author4|Third Coauthor}}
The rules for one coauthor name and multiple coauthor names are different. For a single name in {{para|coauthor}}:
:must have at least one name component with up to three others allowed ({{para|coauthor|Bono}}, {{para|coauthor|John Philip Sousa}} {{para|coauthor|Matakoni, J. L. B.}}
::
:where
:
::any letter, period, apostrophe, or hyphen
:name may be prefixed with and
or &
:
::{{para|coauthor|and John Philip Sousa}} {{para|coauthor|& Matakoni, J. L. B.}} (these prefixes are removed)
For multiple (2–9) names in {{para|coauthor}} each name:
:any letter, period, apostrophe, hyphen, spaces
:all but the last name may be wikilinked (
but not
)
:the last name in the list may be separated with ; and
or ; &
(these prefixes are removed)
The individual authors listed in {{para|coauthor}} must be separated by a semicolon.
{{para|coauthor}} may not end with a semicolon.
The script does not evaluate or validate the content of {{para|coauthor}}.
Ancillary tasks
This script also:
- adds {{para|displayauthors|9}} when replacement results in nine authors,
- removes Wikimarkup italics from
where this text occurs in CS1 citations because the wikimarkup contaminates the citation's COinS metadata and because et al. is properly not italicized (see Help:CS1; and cf., viz., & et al. at MOS:ABBR)et al. - removes empty {{para|coauthor}} parameters
Known shortcomings
- If an editor separates a coauthor in a list of coauthors with a comma instead of a semicolon, the coauthor following the comma is grouped with the author preceding the comma:
- :{{para|coauthor|First Coauthor, Second Coauthor; and Third Coauthor}} becomes:
- ::{{para|author2|First Coauthor, Second Coauthor}}{{para|author3|Third Coauthor}}
To do
Fix single coauthor detection so that it doesn't treat multiple comma-separated coauthors as a single authorDo not do the replacement if the citation contains {{para|ref|harv}} because such edits will break existing {{tlx|sfn}} or {{tlx|harv}} linksRemove {{tlx|citation}} from Capture$1
because it automatically sets {{para|ref|harv}}Prevent replacement if the citation contains {{para|lastn}} or {{para|authorn}} where n is greater than 1- Handle the case where {{para|coauthor}} or {{para|coauthors}} precedes {{para|last}}, {{para|last1}}, {{para|author}}, or {{para|author1}}
Script
public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip)
{
Skip = false;
Summary = "test";
ArticleText = "test \r\n\r\n" + ArticleText;
return ArticleText;
}