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 (Abraham Lincoln but not Lincoln, Abraham)

: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:

  1. adds {{para|displayauthors|9}} when replacement results in nine authors,
  2. removes Wikimarkup italics from et al. 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)
  3. removes empty {{para|coauthor}} parameters

Known shortcomings

  1. 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:
  2. :{{para|coauthor|First Coauthor, Second Coauthor; and Third Coauthor}} becomes:
  3. ::{{para|author2|First Coauthor, Second Coauthor}}{{para|author3|Third Coauthor}}

To do

  1. Fix single coauthor detection so that it doesn't treat multiple comma-separated coauthors as a single author
  2. Do not do the replacement if the citation contains {{para|ref|harv}} because such edits will break existing {{tlx|sfn}} or {{tlx|harv}} links
  3. Remove {{tlx|citation}} from Capture $1 because it automatically sets {{para|ref|harv}}
  4. Prevent replacement if the citation contains {{para|lastn}} or {{para|authorn}} where n is greater than 1
  5. Handle the case where {{para|coauthor}} or {{para|coauthors}} precedes {{para|last}}, {{para|last1}}, {{para|author}}, or {{para|author1}}

Script

wikipedia

en

http://

Category:Pages containing cite templates with deprecated parameters

CategoryListProvider

true

false

false

false

(\{\{\s*[Cc]ite\s*(?:(?:AV media(?! notes))|book|conference|encyclopedia|journal|(?:news(?!group|paper))|press release|sign|techreport|thesis|web)[^}]*)et al(?:\.?|\.?'')([^}]*\}\})

$1et al.$2

Remove italics from et al.

true

true

false

false

IgnoreCase

(\{\{\s*)([Cc]ite\s*(?:(?:AV media(?! notes))|book|conference|encyclopedia|journal|(?:news(?!group|paper))|press release|sign|techreport|thesis|web)[^}]*\|\s*ref\s*=\s*harv[^\|\}]*)

$1BoGuSNonMaTcHiNgStRiNg1$2

Block edits to cites with |ref=harv occurring before |coauthor

true

true

false

false

IgnoreCase

(\{\{\s*)([Cc]ite\s*(?:(?:AV media(?! notes))|book|conference|encyclopedia|journal|(?:news(?!group|paper))|press release|sign|techreport|thesis|web)[^}]*\|\s*(?:author|last)(?:[2-9]|\d\d)\s*=\s*\w[^\|\}]*)

$1BoGuSNonMaTcHiNgStRiNg1$2

Block edits to cites with |lastn= or |authorn (where n>1) that occur before |coauthor

true

true

false

false

IgnoreCase

(\{\{\s*[Cc]ite\s*(?:(?:AV media(?! notes))|book|conference|encyclopedia|journal|(?:news(?!group|paper))|press release|sign|techreport|thesis|web)[^}]*\|\s*(?:authors?|last)1?\s*=\s*[\w\[][^}]*)\|\s*coauthors?\s*=\s*([\w'\[-]+?\s*,?[\w\s\.'\]-]+?);\s?([\w'\[-]+?\s*,?[\w\s\.'\]-]+?);\s?([\w'\[-]+?\s*,?[\w\s\.'\]-]+?);\s?([\w'\[-]+?\s*,?[\w\s\.'\]-]+?);\s?([\w'\[-]+?\s*,?[\w\s\.'\]-]+?);\s?([\w'\[-]+?\s*,?[\w\s\.'\]-]+?);\s?([\w'\[-]+?\s*,?[\w\s\.'\]-]+?);\s?([\w'\[-]+?\s*,?[\w\s\.'\]-]+?);(?:\s*and\b|\s*&)?(\s*\b[\w\s\.,'-]+?)(\s*[\|\}][^}]*)

$1|author2=$2|author3=$3|author4=$4|author5=$5|author6=$6|author7=$7|author8=$8|author9=$9|author10=$10$11

author2; author3; author4; author5; author6; author7; author8; author9;[ &| and] author10

true

true

false

false

IgnoreCase

(\{\{\s*[Cc]ite\s*(?:(?:AV media(?! notes))|book|conference|encyclopedia|journal|(?:news(?!group|paper))|press release|sign|techreport|thesis|web)[^}]*\|\s*(?:authors?|last)1?\s*=\s*[\w\[][^}]*)\|\s*coauthors?\s*=\s*([\w'\[-]+?\s*,?[\w\s\.'\]-]+?);\s?([\w'\[-]+?\s*,?[\w\s\.'\]-]+?);\s?([\w'\[-]+?\s*,?[\w\s\.'\]-]+?);\s?([\w'\[-]+?\s*,?[\w\s\.'\]-]+?);\s?([\w'\[-]+?\s*,?[\w\s\.'\]-]+?);\s?([\w'\[-]+?\s*,?[\w\s\.'\]-]+?);\s?([\w'\[-]+?\s*,?[\w\s\.'\]-]+?);(?:\s*and\b|\s*&)?(\s*\b[\w\s\.,'-]+?)(\s*[\|\}][^}]*)

$1|author2=$2|author3=$3|author4=$4|author5=$5|author6=$6|author7=$7|author8=$8|author9=$9|displayauthors=9$10

author2; author3; author4; author5; author6; author7; author8;[ &| and] author9

true

true

false

false

IgnoreCase

(\{\{\s*[Cc]ite\s*(?:(?:AV media(?! notes))|book|conference|encyclopedia|journal|(?:news(?!group|paper))|press release|sign|techreport|thesis|web)[^}]*\|\s*(?:authors?|last)1?\s*=\s*[\w\[][^}]*)\|\s*coauthors?\s*=\s*([\w'\[-]+?\s*,?[\w\s\.'\]-]+?);\s?([\w'\[-]+?\s*,?[\w\s\.'\]-]+?);\s?([\w'\[-]+?\s*,?[\w\s\.'\]-]+?);\s?([\w'\[-]+?\s*,?[\w\s\.'\]-]+?);\s?([\w'\[-]+?\s*,?[\w\s\.'\]-]+?);\s?([\w'\[-]+?\s*,?[\w\s\.'\]-]+?);(?:\s*and\b|\s*&)?(\s*\b[\w\s\.,'-]+?)(\s*[\|\}][^}]*)

$1|author2=$2|author3=$3|author4=$4|author5=$5|author6=$6|author7=$7|author8=$8$9

author2; author3; author4; author5; author6; author7;[ &| and] author8

true

true

false

false

IgnoreCase

(\{\{\s*[Cc]ite\s*(?:(?:AV media(?! notes))|book|conference|encyclopedia|journal|(?:news(?!group|paper))|press release|sign|techreport|thesis|web)[^}]*\|\s*(?:authors?|last)1?\s*=\s*[\w\[][^}]*)\|\s*coauthors?\s*=\s*([\w'\[-]+?\s*,?[\w\s\.'\]-]+?);\s?([\w'\[-]+?\s*,?[\w\s\.'\]-]+?);\s?([\w'\[-]+?\s*,?[\w\s\.'\]-]+?);\s?([\w'\[-]+?\s*,?[\w\s\.'\]-]+?);\s?([\w'\[-]+?\s*,?[\w\s\.'\]-]+?);(?:\s*and\b|\s*&)?(\s*\b[\w\s\.,'-]+?)(\s*[\|\}][^}]*)

$1|author2=$2|author3=$3|author4=$4|author5=$5|author6=$6|author7=$7$8

author2; author3; author4; author5; author6;[ &| and] author7

true

true

false

false

IgnoreCase

(\{\{\s*[Cc]ite\s*(?:(?:AV media(?! notes))|book|conference|encyclopedia|journal|(?:news(?!group|paper))|press release|sign|techreport|thesis|web)[^}]*\|\s*(?:authors?|last)1?\s*=\s*[\w\[][^}]*)\|\s*coauthors?\s*=\s*([\w'\[-]+?\s*,?[\w\s\.'\]-]+?);([\w'\[-]+?\s*,?[\w\s\.'\]-]+?);([\w'\[-]+?\s*,?[\w\s\.'\]-]+?);([\w'\[-]+?\s*,?[\w\s\.'\]-]+?);(?:\s*and\b|\s*&)?(\s*\b[\w\s\.,'-]+?)(\s*[\|\}][^}]*)

$1|author2=$2|author3=$3|author4=$4|author5=$5|author6=$6$7

author2; author3; author4; author5;[ &| and] author6

true

true

false

false

IgnoreCase

(\{\{\s*[Cc]ite\s*(?:(?:AV media(?! notes))|book|conference|encyclopedia|journal|(?:news(?!group|paper))|press release|sign|techreport|thesis|web)[^}]*\|\s*(?:authors?|last)1?\s*=\s*[\w\[][^}]*)\|\s*coauthors?\s*=([\w'\[-]+?\s*,?[\w\s\.'\]-]+?);([\w'\[-]+?\s*,?[\w\s\.'\]-]+?);([\w'\[-]+?\s*,?[\w\s\.'\]-]+?);(?:\s*and\b|\s*&)?(\s*\b[\w\s\.,'-]+?)(\s*[\|\}][^}]*)

$1|author2=$2|author3=$3|author4=$4|author5=$5$6

author2 author3 author4[;|&|; and] author5

true

true

false

false

IgnoreCase

(\{\{\s*[Cc]ite\s*(?:(?:AV media(?! notes))|book|conference|encyclopedia|journal|(?:news(?!group|paper))|press release|sign|techreport|thesis|web)[^}]*\|\s*(?:authors?|last)1?\s*=\s*[\w\[][^}]*)\|\s*coauthors?\s*=([\w'\[-]+?\s*,?[\w\s\.'\]-]+?);([\w'\[-]+?\s*,?[\w\s\.'\]-]+?);(?:\s*and\b|\s*&)?(\s*\b[\w\s\.,'-]+?)(\s*[\|\}][^}]*)

$1|author2=$2|author3=$3|author4=$4$5

author2 author3[;|&|; and] author4

true

true

false

false

IgnoreCase

(\{\{\s*[Cc]ite\s*(?:(?:AV media(?! notes))|book|conference|encyclopedia|journal|(?:news(?!group|paper))|press release|sign|techreport|thesis|web)[^}]*\|\s*(?:authors?|last)1?\s*=\s*[\w\[][^}]*)\|\s*coauthors?\s*=([\w'\[-]+?\s*,?[\w\s\.'\]-]+?);\s*(?:\s*and\b|\s*&)?(\s*\b[\w\.,-]+\s*[\w\.-]*\s*[\w\.-]*\s*[\w\.-]*)(\s*[\|\}][^}]*)

$1|author2=$2|author3=$3$4

author2[;|&|; and] author3

true

true

false

false

IgnoreCase

(\{\{\s*[Cc]ite\s*(?:(?:AV media(?! notes))|book|conference|encyclopedia|journal|(?:news(?!group|paper))|press release|sign|techreport|thesis|web)[^}]*\|\s*(?:authors?|last)1?\s*=\s*[\w\[][^}]*)\|\s*coauthors?\s*=\s*(?:and\b|with\b|&)?\s*([\w\.,-]+\s*[\w\.-]*\s*[\w\.-]*\s*[\w\.-]*)(\s*[\|\}][^}]*)

$1|author2=$2$3

author2

true

true

false

false

IgnoreCase

(\{\{\s*(?:[Cc]ite (?:(?:AV media(?! notes))|book|conference|encyclopedia|journal|(?:news(?!group|paper))|press release|sign|techreport|thesis|web)|[Cc]itation[^}]+\s*)[^}]*?)\|\s*coauthors?\s*=\s*([\|\}][^}]*)

$1$2

Empty

true

true

false

false

IgnoreCase

(\{\{\s*)BoGuSNonMaTcHiNgStRiNg1([Cc]ite)

$1$2

Restore protected cites

true

true

false

false

IgnoreCase

false

true

false

false

false

false

0

0

false

false

false

false

false

true

2

5

500

true

false

false

30

Task 2: Fix CS1 deprecated coauthor parameter errors (bot trial)

clean up

re-categorisation per CFD

clean up and re-categorisation per CFD

removing category per CFD

subst:'ing

stub sorting

Typo fixing

bad link repair

Fixing links to disambiguation pages

Unicodifying

Task 2: Fix CS1 deprecated coauthor parameter errors (bot trial)

\|\s*ref\s*=\s*harv

true

false

true

false

true

false

false

true

true

false

false

false

false

false

0

false

true

2

false

false

false

true

false

false

false

false

10

Courier New

false

false

false

false

false

true

false

false

false

false

true

true

true

true

false

false

true

true

false

true

false

false

false

false

false

false

false

false

false

true

false

false

false

false

false

C# 2.0

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;

}

false

false

true

false

20

0

true

true

false

false

false

0

0

0

0