User:Monkbot/Task 7: CS1 et al. repair

Monkbot task 7 was created to modify cs1|2 templates that include 'et al.' in the assigned value of author and editor parameters.

A recent change to Module:Citation/CS1 (the engine underlying the and  templates) detects 'et al.' in a variety of forms when they are part of the value assigned to author and editor parameters. Examples are:
 * et al.
 * et al.
 * Smith, John, Et Al
 * Smith John et al.

When these kinds of parameter values are detected, Module:Citation/CS1 adds the page to and also adds a maintenance message. Task 7 operates on the content of this category.

All of the currently supported author and editor parameters and most of their various aliases are supported. authors and editors are not modified because of a bug in Module:Citation/CS1 – see this discussion. authors does not contribute to the  anchor so this parameter is now always 'fixed'.

Task 7 begins by hiding all templates that are not cs1|2. This allows the task to operate on cs1|2 templates that include templates.

Because the task needs to be able to add etal, task 7 finds and removes empty display-authors and display-editors parameters. It also removes empty author and editor name parameters.

When this has been done, task 7 protect certain CS1|2 templates:
 * cs1 with display-authors and/or display-editors – a later version of task 7 may address this kind of template
 * cs1 with harv or cs2, when any of the last aliases contain the et al text because last aliases are made part of the   anchor whereas the content of first aliases are not
 * cs2 ( which automatically sets harv) when any of the last aliases contain the et al text because last aliases are made part of the  anchor whereas the content of first aliases are not
 * cs1|2 where there are author/editor parameters that numerically follow the parameter that contains the et al. text

Unprotected cs1|2 templates are then inspected for author and editor parameters that contain text that matches this pattern:   The pattern does not recognize 'etal' in the name 'Detal', for example.

If the author parameter value is Vancouver style, the code will change the parameter name to vauthors and the et al. text to the keyword  preceded by a comma and a space.

For all other cases, when the pattern is found, the etal text is removed and etal or etal is added to the end of the template. Following this step, task 7 removes the protection from protected CS1 templates.

Because this replacement can result in leftover empty parameters (the first example above), task 7 then searches the article for empty author and editor parameters which it then removes.

The last step is to unhide the templates that were hidden at the beginning.

Article pages that contain will not be edited by this task.