<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mindpowe.red/wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3ACs1_documentation_support</id>
	<title>Module:Cs1 documentation support - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mindpowe.red/wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3ACs1_documentation_support"/>
	<link rel="alternate" type="text/html" href="https://mindpowe.red/wiki/index.php?title=Module:Cs1_documentation_support&amp;action=history"/>
	<updated>2026-04-05T19:13:42Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.2</generator>
	<entry>
		<id>https://mindpowe.red/wiki/index.php?title=Module:Cs1_documentation_support&amp;diff=1254&amp;oldid=prev</id>
		<title>WikiSysop: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://mindpowe.red/wiki/index.php?title=Module:Cs1_documentation_support&amp;diff=1254&amp;oldid=prev"/>
		<updated>2020-08-25T19:08:15Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 19:08, 25 August 2020&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>WikiSysop</name></author>
		
	</entry>
	<entry>
		<id>https://mindpowe.red/wiki/index.php?title=Module:Cs1_documentation_support&amp;diff=1253&amp;oldid=prev</id>
		<title>en&gt;Trappist the monk at 21:41, 11 July 2020</title>
		<link rel="alternate" type="text/html" href="https://mindpowe.red/wiki/index.php?title=Module:Cs1_documentation_support&amp;diff=1253&amp;oldid=prev"/>
		<updated>2020-07-11T21:41:56Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;require('Module:No globals');&lt;br /&gt;
local getArgs = require ('Module:Arguments').getArgs;&lt;br /&gt;
&lt;br /&gt;
local cfg = mw.loadData ('Module:Citation/CS1/Configuration');					-- load the configuration module&lt;br /&gt;
&lt;br /&gt;
local exclusion_lists = {														-- TODO: move these tables into a separate ~/data module and mw.loadData() it&lt;br /&gt;
	['cite book'] = {&lt;br /&gt;
		['agency'] = true,&lt;br /&gt;
		['air-date'] = true,&lt;br /&gt;
		['arxiv'] = true,&lt;br /&gt;
		['biorxiv'] = true,&lt;br /&gt;
		['citeseerx'] = true,&lt;br /&gt;
		['class'] = true,&lt;br /&gt;
		['conference'] = true,&lt;br /&gt;
		['conference-format'] = true,&lt;br /&gt;
		['conference-url'] = true,&lt;br /&gt;
		['degree'] = true,&lt;br /&gt;
		['department'] = true,&lt;br /&gt;
		['display-interviewers'] = true,&lt;br /&gt;
		['docket'] = true,&lt;br /&gt;
		['episode'] = true,&lt;br /&gt;
		['interviewer#'] = true,&lt;br /&gt;
		['interviewer-first#'] = true,&lt;br /&gt;
		['interviewer-link#'] = true,&lt;br /&gt;
		['interviewer-mask#'] = true,&lt;br /&gt;
		['ismn'] = true,&lt;br /&gt;
		['issn'] = true,&lt;br /&gt;
		['issue'] = true,&lt;br /&gt;
		['jfm'] = true,&lt;br /&gt;
		['journal'] = true,&lt;br /&gt;
		['jstor'] = true,&lt;br /&gt;
		['mailinglist'] = true,&lt;br /&gt;
		['message-id'] = true,&lt;br /&gt;
		['minutes'] = true,&lt;br /&gt;
		['MR'] = true,&lt;br /&gt;
		['network'] = true,&lt;br /&gt;
		['number'] = true,&lt;br /&gt;
		['RFC'] = true,&lt;br /&gt;
		['script-journal'] = true,&lt;br /&gt;
		['season'] = true,&lt;br /&gt;
		['section'] = true,&lt;br /&gt;
		['sections'] = true,&lt;br /&gt;
		['series-link'] = true,&lt;br /&gt;
		['series-number'] = true,&lt;br /&gt;
		['series-separator'] = true,&lt;br /&gt;
		['sheet'] = true,&lt;br /&gt;
		['sheets'] = true,&lt;br /&gt;
		['SSRN'] = true,&lt;br /&gt;
		['station'] = true,&lt;br /&gt;
		['time'] = true,&lt;br /&gt;
		['time-caption'] = true,&lt;br /&gt;
		['trans-article'] = true,&lt;br /&gt;
		['trans-journal'] = true,&lt;br /&gt;
		['transcript'] = true,&lt;br /&gt;
		['transcript-format'] = true,&lt;br /&gt;
		['transcript-url'] = true,&lt;br /&gt;
		['ZBL'] = true,&lt;br /&gt;
		},&lt;br /&gt;
	['cite journal'] = {&lt;br /&gt;
		['agency'] = true,&lt;br /&gt;
		['air-date'] = true,&lt;br /&gt;
		['book-title'] = true,&lt;br /&gt;
		['chapter'] = true,&lt;br /&gt;
		['chapter-format'] = true,&lt;br /&gt;
		['chapter-url'] = true,&lt;br /&gt;
		['chapter-url-access'] = true,&lt;br /&gt;
		['class'] = true,&lt;br /&gt;
		['conference'] = true,&lt;br /&gt;
		['conference-format'] = true,&lt;br /&gt;
		['conference-url'] = true,&lt;br /&gt;
		['contribution'] = true,&lt;br /&gt;
		['contributor#'] = true,&lt;br /&gt;
		['contributor-first#'] = true,&lt;br /&gt;
		['contributor-link#'] = true,&lt;br /&gt;
		['contributor-mask#'] = true,&lt;br /&gt;
		['degree'] = true,&lt;br /&gt;
		['department'] = true,&lt;br /&gt;
		['display-interviewers'] = true,&lt;br /&gt;
		['docket'] = true,&lt;br /&gt;
		['edition'] = true,&lt;br /&gt;
		['editor#'] = true,&lt;br /&gt;
		['editor-first#'] = true,&lt;br /&gt;
		['editor-link#'] = true,&lt;br /&gt;
		['editor-mask#'] = true,&lt;br /&gt;
		['editors'] = true,&lt;br /&gt;
		['encyclopedia'] = true,&lt;br /&gt;
		['episode'] = true,&lt;br /&gt;
		['ignore-isbn-error'] = true,&lt;br /&gt;
		['interviewer#'] = true,&lt;br /&gt;
		['interviewer-first#'] = true,&lt;br /&gt;
		['interviewer-link#'] = true,&lt;br /&gt;
		['interviewer-mask#'] = true,&lt;br /&gt;
		['isbn'] = true,&lt;br /&gt;
		['ismn'] = true,&lt;br /&gt;
		['LCCN'] = true,&lt;br /&gt;
		['mailinglist'] = true,&lt;br /&gt;
		['message-id'] = true,&lt;br /&gt;
		['minutes'] = true,&lt;br /&gt;
		['network'] = true,&lt;br /&gt;
		['script-chapter'] = true,&lt;br /&gt;
		['season'] = true,&lt;br /&gt;
		['section'] = true,&lt;br /&gt;
		['sections'] = true,&lt;br /&gt;
		['series-link'] = true,&lt;br /&gt;
		['series-number'] = true,&lt;br /&gt;
		['series-separator'] = true,&lt;br /&gt;
		['sheet'] = true,&lt;br /&gt;
		['sheets'] = true,&lt;br /&gt;
		['station'] = true,&lt;br /&gt;
		['time'] = true,&lt;br /&gt;
		['time-caption'] = true,&lt;br /&gt;
		['trans-article'] = true,&lt;br /&gt;
		['transcript'] = true,&lt;br /&gt;
		['transcript-format'] = true,&lt;br /&gt;
		['transcript-url'] = true,&lt;br /&gt;
		},&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
--[[-------------------------&amp;lt; A D D _ T O _ L I S T &amp;gt;---------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
adds code/name pair to code_list and name/code pair to name_list; code/name pairs in override_list replace those&lt;br /&gt;
taken from the MediaWiki list; these are marked with a superscripted dagger.&lt;br /&gt;
&lt;br /&gt;
|script-&amp;lt;param&amp;gt;= lang codes always use override names so dagger is omitted&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function add_to_list (code_list, name_list, override_list, code, name, dagger)&lt;br /&gt;
	if false == dagger then&lt;br /&gt;
		dagger = '';															-- no dagger for |script-&amp;lt;param&amp;gt;= codes and names&lt;br /&gt;
	else&lt;br /&gt;
		dagger = '&amp;lt;sup&amp;gt;†&amp;lt;/sup&amp;gt;';												-- dagger for all other lists using override&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if override_list[code] then													-- look in the override table for this code&lt;br /&gt;
		code_list[code] = override_list[code] .. dagger;						-- use the name from the override table; mark with dagger&lt;br /&gt;
		name_list[override_list[code]] = code .. dagger;&lt;br /&gt;
	else&lt;br /&gt;
		code_list[code] = name;													-- use the MediaWiki name and code&lt;br /&gt;
		name_list[name] = code;&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[-------------------------&amp;lt; L I S T _ F O R M A T &amp;gt;---------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
formats key/value pair into a string for rendering&lt;br /&gt;
	['k'] = 'v'	→ k: v&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function list_format (result, list)&lt;br /&gt;
	for k, v in pairs (list)	do&lt;br /&gt;
		table.insert (result, k .. ': ' .. v);&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[-------------------------&amp;lt; L A N G _ L I S T E R &amp;gt;---------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Module entry point&lt;br /&gt;
&lt;br /&gt;
Crude documentation tool that returns one of several lists of language codes and names.&lt;br /&gt;
&lt;br /&gt;
Used in Template:Citation Style documentation/language/doc&lt;br /&gt;
&lt;br /&gt;
{{#invoke:cs1 documentation support|lang_lister|list=&amp;lt;selector&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;selector&amp;gt; is one of the values:&lt;br /&gt;
	2char – list of ISO 639-1 codes and names sorted by code&lt;br /&gt;
	3char – list of ISO 639-2, -3 codes and names sorted by code&lt;br /&gt;
	ietf – list of IETF language tags and names sorted by tag -- partial support for these by cs1|2 |language= parameter&lt;br /&gt;
	name – list of language names and codes sorted by name -- IETF tags omitted because not supported by cs1|2 |language= parameter&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function lang_lister (frame)&lt;br /&gt;
	local source_list = mw.language.fetchLanguageNames(mw.getContentLanguage():getCode(), 'all');&lt;br /&gt;
	local override = cfg.lang_code_remap;&lt;br /&gt;
	local code_1_list={};&lt;br /&gt;
	local code_2_list={};&lt;br /&gt;
	local ietf_list={};&lt;br /&gt;
	local name_list={};&lt;br /&gt;
	&lt;br /&gt;
	if not ({['2char']=true, ['3char']=true, ['ietf']=true, ['name']=true})[frame.args.list] then&lt;br /&gt;
		return '&amp;lt;span style=&amp;quot;font-size:100%&amp;quot; class=&amp;quot;error&amp;quot;&amp;gt;unknown list selector: ' .. frame.args.list .. '&amp;lt;/span&amp;gt;';&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	for code, name in pairs (source_list) do&lt;br /&gt;
		if 2 == code:len() then&lt;br /&gt;
			add_to_list (code_1_list, name_list, override, code, name);&lt;br /&gt;
		elseif 3 == code:len() then&lt;br /&gt;
			add_to_list (code_2_list, name_list, override, code, name);&lt;br /&gt;
		else																	-- ietf codes only partically supported by cs1|2 |language= parameter&lt;br /&gt;
			add_to_list (ietf_list, name_list, override, code, name);&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local result = {};&lt;br /&gt;
	local out = {};&lt;br /&gt;
&lt;br /&gt;
	if '2char' == frame.args.list then&lt;br /&gt;
		list_format (result, code_1_list);&lt;br /&gt;
	elseif '3char' == frame.args.list then&lt;br /&gt;
		list_format (result, code_2_list);&lt;br /&gt;
	elseif 'ietf' == frame.args.list then&lt;br /&gt;
		list_format (result, ietf_list);&lt;br /&gt;
	else																		--must be 'name'&lt;br /&gt;
		list_format (result, name_list);&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	table.sort (result);&lt;br /&gt;
	table.insert (result, 1, '&amp;lt;div class=&amp;quot;div-col columns column-width&amp;quot; style=&amp;quot;column-width:20em&amp;quot;&amp;gt;');&lt;br /&gt;
	table.insert (out, table.concat (result, '\n*'));&lt;br /&gt;
	table.insert (out, '&amp;lt;/div&amp;gt;');&lt;br /&gt;
	&lt;br /&gt;
	return table.concat (out, '\n');&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; S C R I P T _ L A N G _ L I S T E R &amp;gt;------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Module entry point&lt;br /&gt;
&lt;br /&gt;
Crude documentation tool that returns list of language codes and names supported by the various |script-&amp;lt;param&amp;gt;= parameters.&lt;br /&gt;
&lt;br /&gt;
used in Help:CS1 errors&lt;br /&gt;
&lt;br /&gt;
{{#invoke:cs1 documentation support|script_lang_lister}}&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function script_lang_lister ()&lt;br /&gt;
	local lang_code_src = cfg.script_lang_codes ;								-- get list of allowed script language codes&lt;br /&gt;
	local override = cfg.lang_code_remap;&lt;br /&gt;
	local this_wiki_lang = mw.language.getContentLanguage().code;				-- get this wiki's language&lt;br /&gt;
&lt;br /&gt;
	local code_list = {};														-- interim list of aliases&lt;br /&gt;
	local name_list={};															-- not used; defined here so that we can reuse add_to_list() &lt;br /&gt;
	local out = {};																-- final output (for now an unordered list)&lt;br /&gt;
	&lt;br /&gt;
	for _, code in ipairs (lang_code_src) do									-- loop through the list of codes&lt;br /&gt;
		local name = mw.language.fetchLanguageName (code, this_wiki_lang);		-- get the language name associated with this code&lt;br /&gt;
		add_to_list (code_list, name_list, override, code, name, false);		-- name_list{} not used but provided so that we can reuse add_to_list(); don't add superscript dagger&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local result = {};&lt;br /&gt;
	local out = {};&lt;br /&gt;
&lt;br /&gt;
	list_format (result, code_list);&lt;br /&gt;
&lt;br /&gt;
	table.sort (result);&lt;br /&gt;
	table.insert (result, 1, '&amp;lt;div class=&amp;quot;div-col columns column-width&amp;quot; style=&amp;quot;column-width:20em&amp;quot;&amp;gt;');&lt;br /&gt;
	table.insert (out, table.concat (result, '\n*'));&lt;br /&gt;
	table.insert (out, '&amp;lt;/div&amp;gt;');&lt;br /&gt;
	&lt;br /&gt;
	return table.concat (out, '\n');&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; A L I A S _ L I S T E R &amp;gt;------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
experimental code that lists parameters and their aliases.  Perhaps basis for some sort of documentation?&lt;br /&gt;
&lt;br /&gt;
{{#invoke:cs1 documentation support|alias_lister}}&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function alias_lister ()&lt;br /&gt;
	local alias_src = cfg.aliases;												-- get master list of aliases&lt;br /&gt;
	local key;																	-- key for k/v in a new table&lt;br /&gt;
	local list = {};															-- interim list of aliases&lt;br /&gt;
	local out = {};																-- final output (for now an unordered list)&lt;br /&gt;
	&lt;br /&gt;
	for _, aliases in pairs (alias_src) do										-- loop throu the master list of aliases&lt;br /&gt;
		if 'table' == type (aliases) then										-- table only when there are aliases&lt;br /&gt;
			for i, alias in ipairs (aliases) do									-- loop through all of the aliases&lt;br /&gt;
				if 1 == i then													-- first 'alias' is the canonical parameter name&lt;br /&gt;
					key = alias;												-- so it becomes the key in list&lt;br /&gt;
				else&lt;br /&gt;
					list[key] = list[key] and (list[key] .. ', ' .. alias) or alias;	-- make comma-separated list of aliases&lt;br /&gt;
					list[alias] = 'see ' .. key;								-- make a back reference from this alias to the canonical parameter&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	for k, v in pairs (list) do													-- loop through the list to make a simple unordered list&lt;br /&gt;
		table.insert (out, table.concat ({'*', k, ': ', v}));&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	table.sort (out);															-- sort it&lt;br /&gt;
	return table.concat (out, '\010');											-- concatenate with \n&lt;br /&gt;
--	return (mw.dumpObject (list))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; C A N O N I C A L _ P A R A M _ L I S T E R &amp;gt;----------------------------------&lt;br /&gt;
&lt;br /&gt;
experimental code that lists canonical parameter names.  Perhaps basis for some sort of documentation?&lt;br /&gt;
&lt;br /&gt;
returns a comma separated, alpha sorted, list of the canonical parameters.  If given a template name, excludes&lt;br /&gt;
parameters listed in that template's exclusion_list[&amp;lt;template&amp;gt;]{} table (if a table has been defined).&lt;br /&gt;
&lt;br /&gt;
{{#invoke:cs1 documentation support|canonical_param_lister|&amp;lt;template&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function canonical_param_lister (frame)&lt;br /&gt;
	local template = frame.args[1];&lt;br /&gt;
	if '' == template then&lt;br /&gt;
		template = nil;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if template then&lt;br /&gt;
		template = mw.text.trim (template:lower());&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local alias_src = cfg.aliases;												-- get master list of aliases&lt;br /&gt;
	local id_src = cfg.id_handlers;												-- get master list of identifiers&lt;br /&gt;
	&lt;br /&gt;
	local list = {};															-- interim list of aliases&lt;br /&gt;
	local out = {};																-- final output (for now an unordered list)&lt;br /&gt;
	&lt;br /&gt;
	for _, aliases in pairs (alias_src) do										-- loop through the master list of aliases&lt;br /&gt;
		local name;&lt;br /&gt;
		if 'table' == type (aliases) then										-- table only when there are aliases&lt;br /&gt;
			name = aliases[1];													-- first member of an aliases table is declared canonical&lt;br /&gt;
		else&lt;br /&gt;
			name = aliases;														-- for those parameters that do not have any aliases, the parameter is declared canonical&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		if not template then													-- no template name, add this parameter&lt;br /&gt;
			table.insert (list, name);&lt;br /&gt;
		elseif not exclusion_lists[template] then								-- template name but no exclusion list&lt;br /&gt;
			table.insert (list, name);&lt;br /&gt;
		elseif not exclusion_lists[template][name] then							-- template name and exclusion list but name not in list&lt;br /&gt;
			table.insert (list, name);&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	for k, ids in pairs (id_src) do												-- spin through the list of identifiers&lt;br /&gt;
		local name = id_src[k].parameters[1];									-- get the first (left-most) parameter name&lt;br /&gt;
		local access = id_src[k].custom_access;									-- get the access-icon parameter if it exists for this identifier&lt;br /&gt;
		if not template then													-- no template name&lt;br /&gt;
			table.insert (list, name);											-- add this parameter&lt;br /&gt;
			if access then&lt;br /&gt;
				table.insert (list, access);									-- add this access-icon parameter&lt;br /&gt;
			end&lt;br /&gt;
		elseif not exclusion_lists[template] then								-- template name but no exclusion list&lt;br /&gt;
			table.insert (list, name);&lt;br /&gt;
			if access then&lt;br /&gt;
				table.insert (list, access);&lt;br /&gt;
			end&lt;br /&gt;
		elseif not exclusion_lists[template][name] then							-- template name and exclusion list but name not in list&lt;br /&gt;
			table.insert (list, name);&lt;br /&gt;
			if access then&lt;br /&gt;
				table.insert (list, access);&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	for _, param in ipairs (list) do											-- loop through the list to make a simple unordered list&lt;br /&gt;
		table.insert (out, table.concat ({'*', param}));&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local function comp( a, b )													-- used in following table.sort()&lt;br /&gt;
		return a:lower() &amp;lt; b:lower();&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	table.sort (out, comp);														-- sort the list&lt;br /&gt;
	return table.concat (out, '\010');											-- concatenate with \n&lt;br /&gt;
--	return (mw.dumpObject (list))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; C A N O N I C A L _ N A M E _ G E T &amp;gt;------------------------------------------&lt;br /&gt;
&lt;br /&gt;
returns first (canonical) name when metaparameter is assigned a table of names&lt;br /&gt;
returns name when metaparameter is assigned a single name&lt;br /&gt;
returns empty string when metaparameter name not found in alias_src{}, id_src{}, or id_src[meta].custom_access&lt;br /&gt;
&lt;br /&gt;
metaparameter &amp;lt;metaparam&amp;gt; is the key in Module:Citation/CS1 aliases{} table or id_handlers{} table.  Because access-icon&lt;br /&gt;
don't have &amp;lt;metaparam&amp;gt; keys, per se, we create pseudo &amp;lt;metaparam&amp;gt; keys by appending 'access' to the identifier &amp;lt;metaparam&amp;gt;:&lt;br /&gt;
	the &amp;lt;metaparam&amp;gt; for |doi-access= is, for the purposes of this function, DOIaccess, etc&lt;br /&gt;
&lt;br /&gt;
Some lists of aliases might be better served when a particular alias is identified as the canonical alias for a &lt;br /&gt;
particular use case.  If, for example, &amp;lt;metaparam&amp;gt; Perodical lists:&lt;br /&gt;
	'journal', 'magazine', 'newspaper', 'periodical', 'website', 'work'&lt;br /&gt;
that order works fine for {{cite journal}} documentation but doesn't work so well for {{cite magazine}}, {{cite news}},&lt;br /&gt;
or {{cite web}}.  So, for using this function to document {{cite magazine}} the returned value should be the&lt;br /&gt;
parameter best suited for that template so we can specify magazine in the override (frame.args[2])&lt;br /&gt;
&lt;br /&gt;
While for this function, it would be just as simple to not use the function, this mechanism is implemented here &lt;br /&gt;
to match similar functionality in alias_names_get() (there are slight differences)&lt;br /&gt;
	&amp;lt;override&amp;gt; must exist in the alias list&lt;br /&gt;
	does not apply to the access icon parameters (ignored - these have no aliases)&lt;br /&gt;
&lt;br /&gt;
(and which would be best for {{cite news}}? |newspaper= or |work=? can't solve all of the worlds problems at once).&lt;br /&gt;
&lt;br /&gt;
output format is controlled by |format=&lt;br /&gt;
	plain - renders in plain text in a &amp;lt;span&amp;gt; tag; may have id attribute&lt;br /&gt;
	para - renders as it would in {{para|&amp;lt;param&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
{{#invoke:cs1 documentation support|canonical_name_get|&amp;lt;metaparam&amp;gt;|&amp;lt;override&amp;gt;|id=&amp;lt;attribute&amp;gt;|format=[plain|para]}}&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function canonical_name_get (frame)&lt;br /&gt;
	local alias_src = cfg.aliases;												-- get master list of aliases&lt;br /&gt;
	local id_src = cfg.id_handlers;												-- get master list of identifiers&lt;br /&gt;
	local args = getArgs (frame);&lt;br /&gt;
&lt;br /&gt;
	local name;&lt;br /&gt;
	local meta = args[1]&lt;br /&gt;
	local override = args[2];&lt;br /&gt;
&lt;br /&gt;
	local access;																-- for id-access parameters&lt;br /&gt;
	if meta:match ('^(%u+)access') then											-- the metaparameter (which is not used in ~/Configuration) is id_handlers key concatenated with access: BIBCODEaccess&lt;br /&gt;
		meta, access = meta:gsub ('^(%u+)access', '%1');						-- strip 'access' text from meta and use returned count value as a flag&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if alias_src[meta] then&lt;br /&gt;
		name = alias_src[meta];													-- name is a string or a table&lt;br /&gt;
		if 'table' == type (name) then											-- table only when there are aliases&lt;br /&gt;
			if not override then&lt;br /&gt;
				name = name[1];													-- first member of an aliases table is declared canonical&lt;br /&gt;
			else&lt;br /&gt;
				for _, v in ipairs (name) do									-- here when override is set; spin throu the aliases to make sure override matches alias in table&lt;br /&gt;
					if v == override then&lt;br /&gt;
						name = v;												-- declare override to be the canonical param for this use case&lt;br /&gt;
						break;&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
	elseif id_src[meta]then														-- if there is an id handler&lt;br /&gt;
		if access then															-- and if this is a request for the handler's custom access parameter&lt;br /&gt;
			if id_src[meta].custom_access then									-- if there is a custom access parameter&lt;br /&gt;
				name = id_src[meta].custom_access;								-- use it&lt;br /&gt;
			else&lt;br /&gt;
				return '';														-- nope, return empty string&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			if not override then&lt;br /&gt;
				name = id_src[meta].parameters[1];								-- get canonical id handler parameter&lt;br /&gt;
			else&lt;br /&gt;
				for _, v in ipairs (id_src[meta].parameters) do					-- here when override is set; spin throu the aliases to make sure override matches alias in table&lt;br /&gt;
					if v == override then&lt;br /&gt;
						name = v;												-- declare override to be the canonical param for this use case&lt;br /&gt;
						break;&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		return '';																-- metaparameter not specified, or no such metaparameter&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if 'plain' == args.format then												-- format and return the output&lt;br /&gt;
		if args.id then&lt;br /&gt;
			return string.format ('&amp;lt;span id=&amp;quot;%s&amp;quot;&amp;gt;%s&amp;lt;/span&amp;gt;', args.id, name);	-- plain text with id attribute&lt;br /&gt;
		else&lt;br /&gt;
			return name;														-- plain text&lt;br /&gt;
		end&lt;br /&gt;
	elseif 'para' == args.format then&lt;br /&gt;
		return string.format ('&amp;lt;code class=&amp;quot;nowrap&amp;quot;&amp;gt;|%s=&amp;lt;/code&amp;gt;', name);		-- same as {{para|&amp;lt;param&amp;gt;}}&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return string.format ('&amp;lt;b id=&amp;quot;%s&amp;quot;&amp;gt;%s&amp;lt;/b&amp;gt;', args.id or '', name);			-- because {{csdoc}} bolds param names&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; A L I A S _ N A M E S _ G E T &amp;gt;------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
returns list of aliases for metaparameter &amp;lt;metaparam&amp;gt;&lt;br /&gt;
returns empty string when there are no aliases&lt;br /&gt;
returns empty string when &amp;lt;metaparam&amp;gt; name not found in alias_src{} or id_src{}; access icon parameters have no aliases so ignored&lt;br /&gt;
&lt;br /&gt;
metaparameter &amp;lt;metaparam&amp;gt; is the key in Module:Citation/CS1 aliases{} table or id_handlers{} table.&lt;br /&gt;
&lt;br /&gt;
Some lists of aliases might be better served when a particular alias is identified as the canonical alias for a &lt;br /&gt;
particular use case.  If, for example, &amp;lt;metaparam&amp;gt; Perodical lists:&lt;br /&gt;
	'journal', 'magazine', 'newspaper', 'periodical', 'website', 'work'&lt;br /&gt;
that order works fine for {{cite journal}} documentation but doesn't work so well for {{cite magazine}}, {{cite news}},&lt;br /&gt;
or {{cite web}}.  So, for using this function to document {{cite magazine}} the returned value should be the&lt;br /&gt;
aliases that are not best suited for that template so we can specify magazine in the override (frame.args[2])&lt;br /&gt;
to be the canonical parameter so it won't be listed with the rest of the aliases (normal canonical journal will be)&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;override&amp;gt; must exist in the alias list except:&lt;br /&gt;
		when &amp;lt;override&amp;gt; value is 'all', returns the canonical parameter plus all of the aliases&lt;br /&gt;
&lt;br /&gt;
output format is controlled by |format=&lt;br /&gt;
	plain - renders in plain text in a &amp;lt;span&amp;gt; tag; may have id attribute&lt;br /&gt;
	para - renders as it would in {{para|&amp;lt;param&amp;gt;}}&lt;br /&gt;
	when not specified, refurns the default bold format used for {{csdoc}}&lt;br /&gt;
&lt;br /&gt;
{{#invoke:cs1 documentation support|alias_name_get|&amp;lt;metaparam&amp;gt;|&amp;lt;override&amp;gt;|format=[plain|para]}}&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function alias_names_get (frame)&lt;br /&gt;
	local alias_src = cfg.aliases;												-- get master list of aliases&lt;br /&gt;
	local id_src = cfg.id_handlers;												-- get master list of identifiers&lt;br /&gt;
	local args = getArgs (frame);&lt;br /&gt;
	&lt;br /&gt;
	local meta = args[1];&lt;br /&gt;
	local override = args[2];&lt;br /&gt;
&lt;br /&gt;
	local out = {};&lt;br /&gt;
	local source;																-- selected parameter or id aliases list&lt;br /&gt;
	local aliases;&lt;br /&gt;
&lt;br /&gt;
	source = alias_src[meta] or (id_src[meta] and id_src[meta].parameters);&lt;br /&gt;
	if not source then&lt;br /&gt;
		if meta:match ('%u+access') then&lt;br /&gt;
			return 'no' == args.none and '' or 'none';							-- custom access parameters don't have aliases&lt;br /&gt;
		else&lt;br /&gt;
			return '';															-- no such meta&lt;br /&gt;
		end&lt;br /&gt;
	elseif not source[2] then													-- id_source[meta] is always a table; if no second member, no aliases&lt;br /&gt;
		return 'no' == args.none and '' or 'none';&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if not override then&lt;br /&gt;
		aliases = source;														-- normal skip-canonical param case&lt;br /&gt;
	else&lt;br /&gt;
		local flag = 'all' == override and true or nil;							-- so that we know that &amp;lt;override&amp;gt; parameter is a valid alias; spoof when override == 'all'&lt;br /&gt;
		aliases = {[1] = ''};													-- spoof to push alias_src[meta][1] and id_src[meta][1] into aliases[2]&lt;br /&gt;
		for _, v in ipairs (source) do											-- here when override is set; spin through the aliases to make sure override matches alias in table&lt;br /&gt;
			if v ~= override then&lt;br /&gt;
				table.insert (aliases, v);										-- add all but overridden param to the the aliases list for this use case&lt;br /&gt;
			else&lt;br /&gt;
				flag = true;													-- set the flag so we know that &amp;lt;override&amp;gt; is a valid alias&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		if not flag then&lt;br /&gt;
			aliases = {}														-- unset the table as error indicator&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if 'table' == type (aliases) then											-- table only when there are aliases&lt;br /&gt;
		for i, alias in ipairs (aliases) do&lt;br /&gt;
			if 1 ~= i then														-- aliases[1] is the canonical name; don't include it&lt;br /&gt;
				if 'plain' == args.format then									-- format and return the output&lt;br /&gt;
					table.insert (out, alias);									-- plain text&lt;br /&gt;
				elseif 'para' == args.format then&lt;br /&gt;
					table.insert (out, string.format ('&amp;lt;code class=&amp;quot;nowrap&amp;quot;&amp;gt;|%s=&amp;lt;/code&amp;gt;', alias));	-- same as {{para|&amp;lt;param&amp;gt;}}&lt;br /&gt;
				else&lt;br /&gt;
					table.insert (out, string.format (&amp;quot;'''%s'''&amp;quot;, alias));		-- because csdoc bolds param names&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		return table.concat (out, ', ');										-- make pretty list and quit&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return 'no' == args.none and '' or 'none';									-- no metaparameter with that name or no aliases&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; I S _ B O O K _ C I T E _ T E M P L A T E &amp;gt;------------------------------------&lt;br /&gt;
&lt;br /&gt;
fetch the title of the current page; if it is a preprint template, return true; empty string else&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local book_cite_templates = {&lt;br /&gt;
	['citation'] = true,&lt;br /&gt;
	['cite book'] = true,&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
local function is_book_cite_template ()&lt;br /&gt;
	local title = mw.title.getCurrentTitle().rootText;							-- get title of current page without namespace and without sub-pages; from Template:Cite book/new -&amp;gt; Cite book&lt;br /&gt;
	&lt;br /&gt;
	title = title and title:lower() or '';&lt;br /&gt;
	return book_cite_templates[title] or '';&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; I S _ L I M I T E D _ P A R A M _ T E M P L A T E &amp;gt;----------------------------&lt;br /&gt;
&lt;br /&gt;
fetch the title of the current page; if it is a preprint template, return true; empty string else&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local limited_param_templates = {												-- if ever there is a need to fetch info from ~/Whitelist then&lt;br /&gt;
	['cite arxiv'] = true,														-- this list could also be fetched from there&lt;br /&gt;
	['cite biorxiv'] = true,&lt;br /&gt;
	['citeseerx'] = true,&lt;br /&gt;
	['ssrn'] = true,&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
local function is_limited_param_template ()&lt;br /&gt;
	local title = mw.title.getCurrentTitle().rootText;							-- get title of current page without namespace and without sub-pages; from Template:Cite book/new -&amp;gt; Cite book&lt;br /&gt;
	&lt;br /&gt;
	title = title and title:lower() or '';&lt;br /&gt;
	return limited_param_templates[title] or '';&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; H E A D E R _ M A K E &amp;gt;--------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
makes a section header from &amp;lt;header_text&amp;gt; and &amp;lt;level&amp;gt;; &amp;lt;level&amp;gt; defaults to 2; cannot be less than 2&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function header_make (frame)&lt;br /&gt;
	local args = getArgs (frame);&lt;br /&gt;
&lt;br /&gt;
	if not args[1] then&lt;br /&gt;
		return '';																-- no header text&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local level = args[2] and tonumber (args[2]) or 2;&lt;br /&gt;
	&lt;br /&gt;
	level = string.rep ('=', level);&lt;br /&gt;
	return level .. args[1] .. level;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; I D _ L I M I T S _ G E T &amp;gt;----------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
return the limit values for named identifier parameters that have &amp;lt;id&amp;gt; limits (pmc, pmid, ssrn, s2cid); the return&lt;br /&gt;
value used in template documentation and error message help-text&lt;br /&gt;
&lt;br /&gt;
{{#invoke:Cs1 documentation support|id_limits_get|&amp;lt;id&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function id_limits_get (frame)&lt;br /&gt;
	local args = getArgs (frame);&lt;br /&gt;
	local handlers = cfg.id_handlers;											-- get id_handlers {} table from ~/Configuration&lt;br /&gt;
&lt;br /&gt;
	return args[1] and handlers[args[1]:upper()].id_limit or '';&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[-------------------------&amp;lt; E X P O R T E D   F U N C T I O N S &amp;gt;------------------------------------------&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
return {&lt;br /&gt;
	alias_lister = alias_lister,&lt;br /&gt;
	alias_names_get = alias_names_get,&lt;br /&gt;
	canonical_param_lister = canonical_param_lister,&lt;br /&gt;
	canonical_name_get = canonical_name_get,&lt;br /&gt;
	header_make = header_make,&lt;br /&gt;
	id_limits_get = id_limits_get,&lt;br /&gt;
	is_book_cite_template = is_book_cite_template,&lt;br /&gt;
	is_limited_param_template = is_limited_param_template,&lt;br /&gt;
	lang_lister = lang_lister,&lt;br /&gt;
	script_lang_lister = script_lang_lister,&lt;br /&gt;
	};&lt;/div&gt;</summary>
		<author><name>en&gt;Trappist the monk</name></author>
		
	</entry>
</feed>