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 Citation Style 1 and Citation Style 2 templates) detects 'et al.' in a variety of forms when they are part of the value assigned to author and editor parameters. Examples are:

|author2=et al.
|author2=''et al.''
|author=Smith, John, Et Al
|editor-last=Smith |editor-first=John ''et al.''

When these kinds of parameter values are detected, Module:Citation/CS1 adds the page to Category:CS1 maint: Explicit use of et al. 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 CITEREF 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 |display-authors=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=<value> and/or |display-editors=<value> – a later version of task 7 may address this kind of template
  • cs1 with |ref=harv or |mode=cs2, when any of the |last= aliases contain the et al text because |last= aliases are made part of the CITEREF anchor whereas the content of |first= aliases are not
  • cs2 ({{citation}} which automatically sets |ref=harv) when any of the |last= aliases contain the et al text because |last= aliases are made part of the CITEREF 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: [,;]?\s*'{0,2}\b[Ee][Tt]\s*[Aa][Ll]\b\.?'{0,2}\.? 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 etal preceded by a comma and a space.

For all other cases, when the pattern is found, the etal text is removed and |display-authors=etal or |display-editors=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 {{bots|deny=Monkbot 7}} will not be edited by this task.