break;
end
end
end
end
else
return ''; -- metaparameter not specified, or no such metaparameter
end  
if 'plain' == args.format then -- format and return the output
if args.id then
return string.format ('<span id="%s">%s</span>', args.id, name); -- plain text with id attribute
else
return name; -- plain text
end
elseif 'para' == args.format then
return string.format ('<code>|%s=</code>', name); -- same as
end  
return string.format ('<b id="%s">%s</b>', args.id or '', name); -- because bolds param names
end  
--[[--------------------------< A L I A S _ N A M E S _ G E T >------------------------------------------------  
returns list of aliases for metaparameter <metaparam>
returns empty string when there are no aliases
returns empty string when <metaparam> name not found in alias_src{} or id_src{}; access icon parameters have no aliases so ignored  
metaparameter <metaparam> is the key in Module:Citation/CS1 aliases{} table or id_handlers{} table.  
Some lists of aliases might be better served when a particular alias is identified as the canonical alias for a
particular use case. If, for example, <metaparam> Perodical lists:
'journal', 'magazine', 'newspaper', 'periodical', 'website', 'work'
that order works fine for documentation but doesn't work so well for , ,
or . So, for using this function to document the returned value should be the
aliases that are not best suited for that template so we can specify magazine in the override (.args[2])
to be the canonical parameter so it won't be listed with the rest of the aliases (normal canonical journal will be)  
<override> must exist in the alias list except:
when <override> value is 'all', returns the canonical parameter plus all of the aliases  
output format is controlled by |format=
plain - renders in plain text in a <span> tag; may have id attribute
para - renders as it would in
when not specified, refurns the default bold format used for  
local function alias_names_get
local alias_src = cfg.aliases; -- get master list of aliases
local id_src = cfg.id_handlers; -- get master list of identifiers
local args = getArgs ;  
local meta = args[1];
local override = args[2];  
local out = {};
local source; -- selected parameter or id aliases list
local aliases;  
source = alias_src[meta] or (id_src[meta] and id_src[meta].parameters);
if not source then
if meta:match ('%u+access') then
return 'no' == args. and * or *; -- custom access parameters don't have aliases
else
return ''; -- no such meta
end
elseif not source[2] then -- id_source[meta] is always a table; if no second member, no aliases
return 'no' == args. and * or *;
end  
if not override then
aliases = source; -- normal skip-canonical param case
else
local flag = 'all' == override and true or nil; -- so that we know that <override> parameter is a valid alias; spoof when override == 'all'
aliases = {[1] = ''}; -- spoof to push alias_src[meta][1] and id_src[meta][1] into aliases[2]
for _, v in ipairs (source) do -- here when override is set; spin through the aliases to make sure override matches alias in table
if v ~= override then
table.insert (aliases, v); -- add all but overridden param to the the aliases list for this use case
else
flag = true; -- set the flag so we know that <override> is a valid alias
end
end
if not flag then
aliases = {} -- unset the table as error indicator
end
end  
if 'table' == type (aliases) then -- table only when there are aliases
for i, alias in ipairs (aliases) do
if 1 ~= i then -- aliases[1] is the canonical name; don't include it
if 'plain' == args.format then -- format and return the output
table.insert (out, alias); -- plain text
elseif 'para' == args.format then
table.insert (out, string.format ('<code>|%s=</code>', alias)); -- same as
else
table.insert (out, string.format ("**%s**", alias)); -- because csdoc bolds param names
end
end
end  
return table.concat (out, ', '); -- make pretty list and quit
end  
return 'no' == args. and * or *; -- no metaparameter with that name or no aliases
end  
----------------------------< I S _ B O O K _ C I T E _ T E M P L A T E >------------------------------------  
fetch the title of the current page; if it is a preprint template, return true; empty string else  
local book_cite_templates = {
['citation'] = true,
['cite book'] = true,
}  
local function is_book_cite_template
local title = mw.title.getCurrentTitle.rootText; -- get title of current page without namespace and without sub-pages; from Template:Cite book/new -> Cite book  
title = title and title:lower or '';
return book_cite_templates[title] or '';
end  
----------------------------< I S _ L I M I T E D _ P A R A M _ T E M P L A T E >----------------------------  
fetch the title of the current page; if it is a preprint template, return true; empty string else  
local limited_param_templates = { -- if ever there is a need to fetch info from ~/Whitelist then
['cite arxiv'] = true, -- this list could also be fetched from there
['cite biorxiv'] = true,
['citeseerx'] = true,
['ssrn'] = true,
}  
local function is_limited_param_template
local title = mw.title.getCurrentTitle.rootText; -- get title of current page without namespace and without sub-pages; from Template:Cite book/new -> Cite book  
title = title and title:lower or '';
return limited_param_templates[title] or '';
end  
----------------------------< H E A D E R _ M A K E >--------------------------------------------------------  
makes a section header from <header_text> and <level>; <level> defaults to 2; cannot be less than 2  
local function _header_make (args)
if not args[1] then
return ''; -- no header text
end  
local level = args[2] and tonumber (args[2]) or 2;  
level = string.rep ('=', level);
return level .. args[1] .. level;
end  
----------------------------< H E A D E R _ M A K E >--------------------------------------------------------  
Entry from an
makes a section header from <header_text> and <level>; <level> defaults to 2; cannot be less than 2  
local function header_make
local args = getArgs ;
return _header_make (args);
end  
----------------------------< I D _ L I M I T S _ G E T >----------------------------------------------------  
return the limit values for named identifier parameters that have <id> limits (pmc, pmid, ssrn, s2cid, oclc, osti, rfc); the return
value used in template documentation and error message help-text  
local function id_limits_get
local args = getArgs ;
local handlers = cfg.id_handlers; -- get id_handlers {} table from ~/Configuration  
return args[1] and handlers[args[1]:upper].id_limit or ('<span>No limit defined for identifier: ' .. (args[1] or '<unknown name>') .. '</span>');
end  
----------------------------< C A T _ L I N K _ M A K E >----------------------------------------------------  
local function cat_link_make (cat)
return table.concat ({':Category:', cat, ''});
end  
----------------------------< S C R I P T _ C A T _ L I S T E R >--------------------------------------------  
utility function to get script-language categories  
local lang_list_t = mw.language.fetchLanguageNames ('en', 'all');  
local function script_cat_lister (script_lang_codes_t, lang_tag_remap_t, cats_list_t)
for _, lang_code in ipairs (script_lang_codes_t) do
local lang_name = lang_tag_remap_t[lang_code] or lang_list_t[lang_code]; -- use remap table to get Bengali instead of Bangla and the like; else use standard MediaWiki names
local cat = 'CS1 uses ' .. lang_name .. '-language script (' .. lang_code .. ')'; -- build a category name
cats_list_t[cat] = 1; -- and save it
end
end  
--select= -- (required) takes one of three values: error, maint, prop
|sandbox= -- takes one value: no
|hdr-lvl= -- base header level (number of == that make a header); default:2 min:2  
This tool will automatically attempt to load a sandbox version of ~/Configuration if one exists.
Setting |sandbox=no will defeat this.  
local function cat_lister
local args = getArgs ;  
local list_live_cats = {}; -- list of live categories