end
else
return '<span>unknown error_conditions key: ' .. (args_t[1] or 'key missing') .. '</span>';
end
end  
--$n= parameters to insert an empty string in the error message:
-> Check |issn= value
-> Check |eissn= value  
error message is rendered at 120% font size; to specify another font size use |size=; must include unit specifier (%, em, etc)  
local function help_text_error_messages
local args_t = getArgs ;
local error_conditions = mw.loadData ('Module:Citation/CS1/Configuration').error_conditions;
-- local span_o = '<span>';
local span_o = '<span>';
local span_c = '</span>';  
local message;
local out = {}; -- output goes here  
if args_t[1] and error_conditions[args_t[1]] then -- must have error_condition key and it must exist
message = error_conditions[args_t[1]].message;
local i=1;
local count;
local rep;
repeat
rep = '$'..i
args_t[rep] = args_t[rep] and args_t[rep]:gsub ('^%s*_%s*$', '') or nil; -- replace empty string marker with actual empty string
message, count = message:gsub (rep, args_t[rep] or rep)
i = i + 1;
until (0 == count);  
table.insert (out, span_o);
table.insert (out, message);
table.insert (out, span_c);
else
return '<span>unknown error_conditions key: ' .. (args_t[1] or 'key missing') .. '</span>';
end  
local out_str = table.concat (out);
return table.concat ({:extensionTag ('templatestyles', '', {src='Module:Citation/CS1/styles.css'}), out_str});
end  
--[[--------------------------< T E M P L A T E S _ T >--------------------------------------------------------  
This table is a k/v table of sequence tables. The keys in this table are collapsed lowercase form of the cs1|2
template names :
Template:Cite AV media -> citeavmedia  
Each subsequence table holds:
[1] documentation page where the TemplateData json is stored ( is the oddball)
[2] key to 'preprint_arguments_t' and unique_arguments_t' tables in Module:Citation/CS1/Whitelist; these keys
dictate which of the basic or limited arguments and numbered arguments tables will be used to validate
the content of the TemplateData  
local templates_t = {
citearxiv = {'Template:Cite_arXiv/doc', 'arxiv'}, -- preprint arguments
citeavmedia = {'Template:Cite AV media/doc', 'audio-visual'}, -- unique arguments
citeavmedianotes = {'Template:Cite AV media notes/doc'}, -- no template data
citebiorxiv = {'Template:Cite bioRxiv/doc', 'biorxiv'}, -- preprint arguments
citebook = {'Template:Cite book/TemplateData'},
citeciteseerx = {'Template:Cite CiteSeerX/doc', 'citeseerx'}, -- no template data; preprint uses limited arguments
citeconference = {'Template:Cite conference/doc', 'conference'}, -- unique arguments
citedocument = {'Template:Cite document/doc', 'document'}, -- special case; uses whitelist.document_parameters_t
citeencyclopedia = {'Template:Cite encyclopedia/doc'},
citeepisode = {'Template:Cite episode/doc', 'episode'}, -- unique arguments
citeinterview = {'Template:Cite interview/doc'},
citejournal = {'Template:Cite journal/doc'},
citemagazine = {'Template:Cite magazine/doc'},
citemailinglist = {'Template:Cite mailing list/doc', 'mailinglist'}, -- unique arguments -- no template data
citemap = {'Template:Cite map/TemplateData', 'map'}, -- unique arguments
citemedrxiv = {'Template:Cite medRxiv/doc', 'medrxiv'}, -- preprint arguments
citenews = {'Template:Cite news/doc'},
citenewsgroup = {'Template:Cite newsgroup/doc', 'newsgroup'}, -- unique arguments
citepodcast = {'Template:Cite podcast/doc'},
citepressrelease = {'Template:Cite press release/doc'},
citereport = {'Template:Cite report/doc', 'report'}, -- unique arguments
citeserial = {'Template:Cite serial/doc', 'serial'}, -- unique arguments -- no template data
citesign = {'Template:Cite sign/doc'},
citespeech = {'Template:Cite speech/doc', 'speech'}, -- unique arguments -- no template data
citessrn = {'Template:Cite SSRN/doc', 'ssrn'}, -- preprint arguments -- no template data
citetechreport = {'Template:Cite tech report/doc'},
citethesis = {'Template:Cite thesis/doc', 'thesis'}, -- unique arguments
citeweb = {'Template:Cite web/doc'},
citation = {'Template:Citation/doc'},
}  
----------------------------< N O _ P A G E _ T E M P L A T E S _ T >----------------------------------------  
local no_page_templates_t = {};  
----------------------------< I D E N T I F I E R _ A L I A S E S _ T >--------------------------------------  
a table of the identifier aliases  
local identifier_aliases_t = {}
for identifier, handler in pairs (cfg.id_handlers) do -- for each identifier
local aliases_t = {}; -- create a table
for _, alias in ipairs (handler.parameters) do -- get the alaises
aliases_t[alias] = true; -- and add them to the table in a form that mimics the whitelist tables
end
identifier_aliases_t[identifier:lower] = aliases_t; -- add new table to the identifier aliases table; use lowercase identifier base name for the key
end  
----------------------------< T E M P L A T E _ D A T A _ J S O N _ G E T >----------------------------------  
get template doc page content and extract the content of the TemplateData tags (case insensitive)  
<template> is the canonical name of the template doc page (with namespace) that holds the template data; usually
Template:Cite xxx/doc (except Template:Cite book/TemplateData)  
local function template_data_json_get (template)
local json = mw.title.new (template):getContent or *; -- get the content of the article or *; new pages edited w/ve do not have 'content' until saved; ve does not preview; phab:T221625
json = json:match ('<[Tt]emplate[Dd]ata>(.-)</[Tt]emplate[Dd]ata>'); -- remove everything exept the content of the TemplatData tags
return json and mw.text.jsonDecode (json); -- decode the json string and return as a table; nil if not found
end  
----------------------------< V A L I D A T E _ D O C U M E N T _ P A R A M >--------------------------------  
looks for <param> (can be the canonical parameter name or can be an alias) in whitelist.document_parameters_t.
When found, returns true; nil else  
<param> is the parameter's name as listed in the TemplateData  
local function validate_document_param (param)
if true == whitelist.document_parameters_t[param] then
return true;
end
end  
----------------------------< V A L I D A T E _ U N I Q U E _ P A R A M >------------------------------------  
looks for <param> (can be the canonical parameter name or can be an alias) in whitelist.basic_arguments{} and if
necessary in whitelist.numbered_arguments{}. When found, returns true; nil else  
<param> is the parameter's name as listed in the TemplateData  
local function validate_basic_param (param)
if true == whitelist.common_parameters_t[param] then
return true;
end
end  
----------------------------< V A L I D A T E _ P R E P R I N T _ P A R A M >--------------------------------  
looks for <param> (can be the canonical parameter name or can be an alias) in whitelist.preprint_arguments_t{} or
whitelist.limited_basic_arguments{} or whitelist.limited_numbered_arguments{}. When found, returns true; nil else  
<param> is the parameter's name as listed in the TemplateData
<key> is key neccessary to look in the appropriate subtable of whitelist.preprint_arguments_t{}  
local function validate_preprint_param (param, key)
if true == whitelist.preprint_arguments_t[key][param] or
true == whitelist.limited_parameters_t[param] then
-- true == whitelist.limited_basic_arguments_t[param] or
-- true == whitelist.limited_numbered_arguments_t[param] then
return true;
end
end  
----------------------------< V A L I D A T E _ U N I Q U E _ P A R A M >------------------------------------  
looks for <param> (can be the canonical parameter name or can be an alias) in whitelist.unique_arguments_t{} or
whitelist.basic_arguments{} or whitelist.numbered_arguments{}. When found, returns true; nil else  
<param> is the parameter's name as listed in the TemplateData
<key> is key neccessary to look in the appropriate subtable of whitelist.unique_arguments_t{}