User:Monkbot/Task 9: Ship infobox lists

Monkbot task 9 was created to standardize lists in ship article infoboxen and operates primarily on the content of.

In the past, the WP:SHIPS infobox usage guide required unbulleted lists for reasons of limited available space and for aesthetics. Editors used a variety of other methods to create lists in infoboxes. These included line break HTML tags and the use of,  and  templates. Problems with these methods are:
 * use of and  make visually 'correct' lists that are not correct for those who use screen readers.  See MOS:ACCESS §Vertical lists.
 * limitations in Mediawiki:Common.css, prevent and  from correctly rendering multi-level lists

description
Ship infoboxen are wiki-tables that contain, at a minimum, two and usually more specialized templates that provide formatting and header data for the infobox. The templates are (required),, , , , and. For the time being, this task only operates on the last three of these though it is expected that it will eventually operate on as well.

standardization
The task begins by standardizing the names of the infobox templates to sentence case and their canonical names if redirects are used.

setup
To constrain operation of this task to the limited area of the infobox table, task 9 hides certain characters and templates. The first step is to hide equal signs (=) in templates that are not ship infobox templates and in templates that are not either of the list templates or  (or their redirect aliases) by replacing the equal signs with the text string. Similarly, the equal sign in, and pipes in templates and wikilinks are hidden using  and   respectively.

Templates that are not infobox or list templates are hidden by replacing the opening and closing curly-brace pairs with  and   respectively. Finally, list templates are hidden with  and   for, and   and   for.

All of this hiding make subsequent rules simpler.

line-break lists
Line break lists are the most common form of list in ship infoboxen. These list usually use some form of but occasionally use. These latter are first converted to. Similarly, the various forms , , etc. are converted to the canonical form  and where more than one of these tags is present in succession, the duplicates are removed.

When the first text in an infobox template parameter is, the tag is removed. Task 9 inserts an asterisk at the start of parameter value and then replaces each occurrence of with.

plainlist
Because templates were hidden during setup, unhide them by replacing   and   with   and. supports the named parameters class, style, and indent. These parameters are not supported by unordered lists in ship infoboxen.

Except for white-space, templates must be the only text in the parameter value. Any text, even empty html comment tags, before or after a will cause the value to be ignored. When this happens, all subsequent templates are also ignored. It is not expected that this limitation will be 'fixed' by this tool.

When infobox parameters hold only templates, the template markup (the   and  ) is removed along with any white-space between the parameter's equal sign and the first line of the  content.

unbulleted list
Because templates were hidden during setup, unhide them by replacing   and   with   and. supports the named parameters class, style, indent, list_style, item_style, and itemn_style. These parameters are not supported by unordered lists in ship infoboxen.

Except for white-space, templates must be the only text in the parameter value. Any text, even empty html comment tags, before or after a will cause the value to be ignored. When this happens, all subsequent templates are also ignored. It is not expected that this limitation will be 'fixed' by this tool.

When infobox parameters hold only templates, the template markup (the   and  ) is removed along with any white-space between the parameter's equal sign and the first parameter of the  template. The individual parameters are split at the pipes into an array of strings. A new string is constructed from the array by adding  and   to each array string as it is concatenated to previous strings.

miscellaneous cleanup
Items in lists within ship infoboxen often take the form

sometimes with or without  on either side of  ; sometimes an   or   is used in place of. Non-breaking spaces are not required at the start of a list item.

Some lists in ship infoboxen prefix a list item in the item text with • (Bullet, U+2022, ) or · (Interpunct, U+00B7,  ) with or without surrounding spaces. When these are found, they are removed.

restoration
All of the above tasks being completed, task 9 unhides pipes (__P1P3__), equals (__3QU4L__), and template open (__0P3N__) and close (__CL0S3__). It then assembles a summary text to be used as an edit summary. If no lists were converted, sets  to   and abandons the edit.