category = '';
end
if true == showerrs then
return string.format (err_msg, prefix, message, sep, param_val, category); -- put it all together
else
return param_val .. category;
end
end  
----------------------------< I N F O B O X _ L I S T S >----------------------------------------------------  
Mediawiki:Common.css imposes limitations on plain, unbulleted lists. The template does not render this correctly:  
The above renders without proper indents for items marked ** and ***.  
If the list is not wrapped in then the above list is rendered with bullets which is contrary to the Infobox ship usage guide.  
This code translates a bulleted list into an html unordered list:  
<ul>
<li>Name 1</li>
<li>Name 2</li>
<ul>
<li>Subname 2a</li>
<ul>
<li>Subname 2a1</li>
</ul>
<li>Subname 2b</li>
</ul>
<li>Name 3</li>
</ul>  
There are rules:
1. The parameter value must begin with a splat but may have leading and trailing whitespace.
2. Each list item after the first must begin on a new line just as is required by normal bulleted lists.
3. When adding a sublevel, the number of splats may increase by one and never more. This is illegal:
- item
- item
When any of these rules are violated, wpsu.unbulleted_list returns the original text and adds the article
to Category:WPSHIPS:Infobox list errors. Error messaging in this function is somewhat sketchy so they are
disabled. After initial adoption, better error messaging could/should be implemented.  
This function receives the content of one parameter:
}  
function wpsu.unbulleted_list
local showerrs = true; -- set to false to hide error messages
local List_item_otag = '<li>'; -- hanging indent markup; everything moves with padding-; first line moved by neg indent  
if nil == .args[1]:match ('^%s*%*') then -- parameter value must begin with a splat (ignoring leading white space)
if .args[1]:match ('<[%s/]*[Bb][Rr][%s/]*>') then -- if the parameter value has a list using variants of
tag
return list_error ('', '&lt;br /> list', '
', .args[1], showerrs); -- return an error message with maintenance category
elseif .args[1]:match ('.+\n%*') then -- if the parameter value has text followed by an unordered list
return list_error ('', 'mixed text and list', '
', .args[1], showerrs); -- return an error message with maintenance category
end
return .args[1]; -- return the parameter as is
end  
local item_table = mw.text.split (mw.text.trim (.args[1]), '\n'); -- trim white space from end then make a table of bulleted items by splitting on newlines
if 1 == #item_table then -- if only one bulleted item, no need for a list
return (item_table[1]:gsub ('^%*%s*', '')); -- trim off the splat and any following white space and done
end  
if item_table[1]:match ('^%*%*+') then -- if first list item uses more than one splat, that's an error
return list_error ('*', 'too many * at start of list', '\n', .args[1], showerrs); -- return an error message with maintenance category
end  
local html_table = {}; -- table to hold the html output
local level = 1; -- used to indicate when a new <ul> is required
local splats = 0; -- number of splats that start each item in the list
local item = ''; -- the item text  
table.insert (html_table, '<ul>') -- this for first <ul> tag; sets no bullets and no indent  
for _,v in ipairs (item_table) do
splats, item = v:match ('(%*+)%s*(.*)'); -- split the item into splats and item text
if nil == splats then -- nil if there is an extra line between items
return list_error ('*', 'list item missing markup', '\n', .args[1], showerrs); -- return an error message with maintenance category
elseif '' == item then
return list_error ('*', 'empty list item', '\n', .args[1], showerrs); -- return an error message with maintenance category
elseif item:match ('^[;:]') then -- if the list item is mixed unordered list / description list markup (*:)
return list_error ('*', 'mixed list type', '\n', .args[1], showerrs); -- return an error message with maintenance category
end  
splats = splats:len; -- change string of splats into a number indicating how many splats there are  
if splats == level then -- if at the same level as previous item
table.insert (html_table, List_item_otag .. item .. '</li>');
elseif splats == level + 1 then -- number of splats can only increase by one
level = splats; -- record the new level
table.insert (html_table, '<ul>'); -- add a new sublist
table.insert (html_table, List_item_otag .. item .. '</li>'); -- and the item
elseif splats < level then -- from three splats to one splat for example
while splats < level do
table.insert (html_table, '</ul>'); -- close each sub <ul> until level and splats match
level = level - 1;
end
table.insert (html_table, List_item_otag .. item .. '</li>'); -- add the item
else -- jumping more than one level up – one splat to three splats for example – is an error
return list_error ('*', 'too many asterisks', '\n', .args[1], showerrs); -- return an error message with maintenance category
end
end  
while 0 < level do
table.insert (html_table, '</ul>'); -- close each <ul> until level counted down to zero
level = level - 1;
end  
return table.concat (html_table, '\n'); -- return the list as a string
end  
--[=[-------------------------< I N F O B O X _ S H I P _ F L A G >--------------------------------------------  
Output of :  
Image syntax:  
This function standardizes the size of flag images in the infobox ship career header by simply overwriting the Size
parameter value in the Image wikilink with |100x28px. This size leave a gap between the top and bottom of the flag image and
the header edge. A similar -side gap of is supplied by .  
]=]  
function wpsu.infobox_ship_flag
if not is_set (.args[1]) then -- if |Ship flag= not set
return ''; -- return empty string
end  
if .args[1]:match ('|[%s%dx]+px%s*') then -- is there a size positional parameter?
.args[1] = .args[1]:gsub('|[%s%dx]+px%s*', '%|100x28px'); -- overwrite it with |100x28px
else
return '<span>malformed flag image</span>'
end
return .args[1]; -- return the modified image
end
return wpsu;