User:Monkbot/Task 2: CS1 deprecated coauthor parameters

This script is intended to pluck some of the low hanging fruit from. Editors often place multiple coauthors in either coauthor or coauthors (these two parameters are aliases of each other so hereafter coauthor) and separate the coauthors with a semicolon with or without a following space. This script replaces coauthor with an appropriate number of authorn parameters beginning with author2.

The script will not do a replacement when:
 * the template contains harv. coauthor is not used when Module:Citation/CS1 creates the  (used by  and the  family of templates) but author2, author3, and author4 are used.
 * the template is a template because this template automatically sets harv.
 * the template contains lastn or authorn where n is greater than 1 and when:
 * lastn or authorn contains a value and precedes coauthor – if a stray author2 is empty and precedes coauthor the replacement author2 value overrides the empty author2; or
 * lastn or authorn with or without an assigned value follows coauthor – a author2 that follows the replacement author2 will override the replacement

When coauthor in CS1 citations have only one coauthor name, or a list of names separated by semicolons, replace coauthor and subsequent semicolons with author2, author3, etc. When coauthor is empty, remove it from the citation. For example replace:
 * First Coauthor; Second Coauthor; Third Coauthor

with
 * First CoauthorSecond CoauthorThird Coauthor

The rules for one coauthor name and multiple coauthor names are different. For a single name in coauthor:
 * must have at least one name component with up to three others allowed (Bono, John Philip Sousa Matakoni, J. L. B.
 * where :
 * any letter, period, apostrophe, or hyphen
 * name may be prefixed with  or  :
 * and John Philip Sousa &amp; Matakoni, J. L. B. (these prefixes are removed)
 * and John Philip Sousa &amp; Matakoni, J. L. B. (these prefixes are removed)

For multiple (2–9) names in 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  or   (these prefixes are removed)

The individual authors listed in coauthor must be separated by a semicolon.

coauthor may not end with a semicolon.

The script does not evaluate or validate the content of coauthor.

Ancillary tasks
This script also:
 * 1) adds 9 when replacement results in nine authors,
 * 2) 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)
 * 3) removes empty 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:
 * First Coauthor, Second Coauthor; and Third Coauthor becomes:
 * First Coauthor, Second CoauthorThird 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 harv because such edits will break existing  or  links
 * 3) Remove  from Capture   because it automatically sets harv
 * 4) Prevent replacement if the citation contains lastn or authorn where n is greater than 1
 * 5) Handle the case where coauthor or coauthors precedes last, last1, author, or author1

Script
  false false   true    false  <Variants /> <ContextChars>20</ContextChars> </Disambiguation> <Special> <namespaceValues> 0    </namespaceValues> <remDupes>true</remDupes> <sortAZ>true</sortAZ> <filterTitlesThatContain>false</filterTitlesThatContain> <filterTitlesThatContainText /> <filterTitlesThatDontContain>false</filterTitlesThatDontContain> <filterTitlesThatDontContainText /> <areRegex>false</areRegex> <opType>0</opType> </Special> <Tool> <ListComparerUseCurrentArticleList>0</ListComparerUseCurrentArticleList> <ListSplitterUseCurrentArticleList>0</ListSplitterUseCurrentArticleList>