<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-Hant-TW">
	<id>http://wiki.lilauid.com/mediawiki/index.php?action=history&amp;feed=atom&amp;title=%E6%A8%A1%E7%B5%84%3ACitation%2FCS1%2FError</id>
	<title>模組:Citation/CS1/Error - 修訂歷史</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.lilauid.com/mediawiki/index.php?action=history&amp;feed=atom&amp;title=%E6%A8%A1%E7%B5%84%3ACitation%2FCS1%2FError"/>
	<link rel="alternate" type="text/html" href="http://wiki.lilauid.com/mediawiki/index.php?title=%E6%A8%A1%E7%B5%84:Citation/CS1/Error&amp;action=history"/>
	<updated>2026-07-01T09:58:55Z</updated>
	<subtitle>本 Wiki 上此頁面的修訂歷史</subtitle>
	<generator>MediaWiki 1.39.1</generator>
	<entry>
		<id>http://wiki.lilauid.com/mediawiki/index.php?title=%E6%A8%A1%E7%B5%84:Citation/CS1/Error&amp;diff=342&amp;oldid=prev</id>
		<title>Lilauid：​建立內容為「----------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------  local z = { 	error_categories = {};														-- for categorizing citations that contain errors 	error_ids = {}; 	message_tail = {}; 	maintenance_cats = {};														-- for categorizing citations that aren&#039;t erroneous per se, but could use a little work 	properties_cats = {};														-- for categorizing citations based on certain pro…」的新頁面</title>
		<link rel="alternate" type="text/html" href="http://wiki.lilauid.com/mediawiki/index.php?title=%E6%A8%A1%E7%B5%84:Citation/CS1/Error&amp;diff=342&amp;oldid=prev"/>
		<updated>2025-09-19T02:18:03Z</updated>

		<summary type="html">&lt;p&gt;建立內容為「--[[--------------------------&amp;lt; F O R W A R D   D E C L A R A T I O N S &amp;gt;-------------------------------------- ]] local z = { 	error_categories = {};														-- for categorizing citations that contain errors 	error_ids = {}; 	message_tail = {}; 	maintenance_cats = {};														-- for categorizing citations that aren&amp;#039;t erroneous per se, but could use a little work 	properties_cats = {};														-- for categorizing citations based on certain pro…」的新頁面&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新頁面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--[[--------------------------&amp;lt; F O R W A R D   D E C L A R A T I O N S &amp;gt;--------------------------------------&lt;br /&gt;
]]&lt;br /&gt;
local z = {&lt;br /&gt;
	error_categories = {};														-- for categorizing citations that contain errors&lt;br /&gt;
	error_ids = {};&lt;br /&gt;
	message_tail = {};&lt;br /&gt;
	maintenance_cats = {};														-- for categorizing citations that aren&amp;#039;t erroneous per se, but could use a little work&lt;br /&gt;
	properties_cats = {};														-- for categorizing citations based on certain properties, language of source for instance&lt;br /&gt;
};&lt;br /&gt;
local cfg;&lt;br /&gt;
local in_array, is_set, substitute, wrap_style;&lt;br /&gt;
local make_internal_link;&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; T H R O W _ E R R O R &amp;gt;-------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Terminate the program with a pre-defined excuse.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function throw_error (arg)&lt;br /&gt;
	error (cfg.internal_errors[arg]);&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; E R R O R _ C O M M E N T &amp;gt;----------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Wraps error messages with css markup according to the state of hidden.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
local function error_comment (content, hidden)&lt;br /&gt;
	return wrap_style (hidden and &amp;#039;hidden-error&amp;#039; or &amp;#039;visible-error&amp;#039;, content);&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; S E T _ E R R O R &amp;gt;--------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Sets an error condition and returns the appropriate error message.  The actual placement of the error message in the output is&lt;br /&gt;
the responsibility of the calling function.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local added_error_cats = {};&lt;br /&gt;
&lt;br /&gt;
local function set_error (error_id, arguments, raw, prefix, suffix)&lt;br /&gt;
	local error_state = cfg.error_conditions[error_id];&lt;br /&gt;
	&lt;br /&gt;
	prefix = prefix or &amp;#039;&amp;#039;;&lt;br /&gt;
	suffix = suffix or &amp;#039;&amp;#039;;&lt;br /&gt;
	&lt;br /&gt;
	if error_state == nil then&lt;br /&gt;
		throw_error (&amp;#039;undefined_error&amp;#039;);&lt;br /&gt;
	elseif is_set (error_state.category) then&lt;br /&gt;
		local category = substitute (error_state.category, arguments);&lt;br /&gt;
		if not added_error_cats[error_id] then&lt;br /&gt;
			table.insert (z.error_categories, category)&lt;br /&gt;
			added_error_cats[error_id] = true;									-- note that we&amp;#039;ve added this category&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local message = substitute (error_state.message, arguments);&lt;br /&gt;
	&lt;br /&gt;
	message = table.concat (&lt;br /&gt;
		{&lt;br /&gt;
		message,&lt;br /&gt;
		&amp;#039; (&amp;#039;,&lt;br /&gt;
		make_internal_link (&lt;br /&gt;
			table.concat (&lt;br /&gt;
				{&lt;br /&gt;
				cfg.messages[&amp;#039;help page link&amp;#039;],&lt;br /&gt;
				&amp;#039;#&amp;#039;,&lt;br /&gt;
				error_state.anchor&lt;br /&gt;
				}),&lt;br /&gt;
			cfg.messages[&amp;#039;help page label&amp;#039;]),&lt;br /&gt;
		&amp;#039;)&amp;#039;&lt;br /&gt;
		});&lt;br /&gt;
	&lt;br /&gt;
	z.error_ids[error_id] = true;&lt;br /&gt;
	if in_array (error_id, {&amp;#039;bare_url_missing_title&amp;#039;, &amp;#039;trans_missing_title&amp;#039;})&lt;br /&gt;
			and z.error_ids[&amp;#039;citation_missing_title&amp;#039;] then&lt;br /&gt;
		return &amp;#039;&amp;#039;, false;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	message = table.concat ({prefix, message, suffix});&lt;br /&gt;
	&lt;br /&gt;
	if raw == true then&lt;br /&gt;
		return message, error_state.hidden;&lt;br /&gt;
	end		&lt;br /&gt;
		&lt;br /&gt;
	return error_comment (message, error_state.hidden);&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; A P P E N D _ E R R O R &amp;gt;--------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Sets an error condition, then appends the appropriate error message to z.message_tail.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function append_error (error_id, arguments, prefix, suffix)&lt;br /&gt;
	table.insert (z.message_tail, {set_error (error_id, arguments, true, prefix, suffix)});&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[-------------------------&amp;lt; I S _ A L I A S _ U S E D &amp;gt;-----------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
This function is used by select_one() to determine if one of a list of alias parameters is in the argument list&lt;br /&gt;
provided by the template.&lt;br /&gt;
&lt;br /&gt;
Input:&lt;br /&gt;
	args – pointer to the arguments table from calling template&lt;br /&gt;
	alias – one of the list of possible aliases in the aliases lists from Module:Citation/CS1/Configuration&lt;br /&gt;
	index – for enumerated parameters, identifies which one&lt;br /&gt;
	enumerated – true/false flag used to choose how enumerated aliases are examined&lt;br /&gt;
	value – value associated with an alias that has previously been selected; nil if not yet selected&lt;br /&gt;
	selected – the alias that has previously been selected; nil if not yet selected&lt;br /&gt;
	error_list – list of aliases that are duplicates of the alias already selected&lt;br /&gt;
&lt;br /&gt;
Returns:&lt;br /&gt;
	value – value associated with alias we selected or that was previously selected or nil if an alias not yet selected&lt;br /&gt;
	selected – the alias we selected or the alias that was previously selected or nil if an alias not yet selected&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function is_alias_used (args, alias, index, enumerated, value, selected, error_list)&lt;br /&gt;
	if enumerated then															-- is this a test for an enumerated parameters?&lt;br /&gt;
		alias = alias:gsub (&amp;#039;#&amp;#039;, index);										-- replace &amp;#039;#&amp;#039; with the value in index&lt;br /&gt;
	else&lt;br /&gt;
		alias = alias:gsub (&amp;#039;#&amp;#039;, &amp;#039;&amp;#039;);											-- remove &amp;#039;#&amp;#039; if it exists&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if is_set (args[alias]) then													-- alias is in the template&amp;#039;s argument list&lt;br /&gt;
		if value ~= nil and selected ~= alias then								-- if we have already selected one of the aliases&lt;br /&gt;
			local skip;&lt;br /&gt;
			for _, v in ipairs (error_list) do									-- spin through the error list to see if we&amp;#039;ve added this alias&lt;br /&gt;
				if v == alias then&lt;br /&gt;
					skip = true;&lt;br /&gt;
					break;														-- has been added so stop looking &lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			if not skip then													-- has not been added so&lt;br /&gt;
				table.insert (error_list, alias);								-- add error alias to the error list&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			value = args[alias];												-- not yet selected an alias, so select this one&lt;br /&gt;
			selected = alias;&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return value, selected;														-- return newly selected alias, or previously selected alias&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; A D D _ M A I N T _ C A T &amp;gt;------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Adds a category to z.maintenance_cats using names from the configuration file with additional text if any.&lt;br /&gt;
To prevent duplication, the added_maint_cats table lists the categories by key that have been added to z.maintenance_cats.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
local added_maint_cats = {};&lt;br /&gt;
local function add_maint_cat (key, arguments)&lt;br /&gt;
	if not added_maint_cats [key] then&lt;br /&gt;
		added_maint_cats [key] = true;											-- note that we&amp;#039;ve added this category&lt;br /&gt;
		table.insert (z.maintenance_cats, substitute (cfg.maint_cats [key], arguments));&lt;br /&gt;
																				-- make name then add to table&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; A D D _ P R O P _ C A T &amp;gt;--------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Adds a category to z.properties_cats using names from the configuration file with additional text if any.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local added_prop_cats = {}														-- list of property categories that have been added to z.properties_cats&lt;br /&gt;
local function add_prop_cat (key, arguments)&lt;br /&gt;
	if not added_prop_cats [key] then&lt;br /&gt;
		added_prop_cats [key] = true;											-- note that we&amp;#039;ve added this category&lt;br /&gt;
		table.insert (z.properties_cats, substitute (cfg.prop_cats [key], arguments));		&lt;br /&gt;
																				-- make name then add to table&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; S E L E C T _ O N E &amp;gt;----------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Chooses one matching parameter from a list of parameters to consider.  The list of parameters to consider is just&lt;br /&gt;
names.  For parameters that may be enumerated, the position of the numerator in the parameter name is identified&lt;br /&gt;
by the &amp;#039;#&amp;#039; so |author-last1= and |author1-last= are represented as &amp;#039;author-last#&amp;#039; and &amp;#039;author#-last&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
Because enumerated parameter |&amp;lt;param&amp;gt;1= is an alias of |&amp;lt;param&amp;gt;= we must test for both possibilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Generates an error if more than one match is present.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function select_one (args, aliases_list, error_condition, index)&lt;br /&gt;
	local value = nil;															-- the value assigned to the selected parameter&lt;br /&gt;
	local selected = &amp;#039;&amp;#039;;														-- the name of the parameter we have chosen&lt;br /&gt;
	local error_list = {};&lt;br /&gt;
&lt;br /&gt;
	if index ~= nil then index = tostring (index); end&lt;br /&gt;
&lt;br /&gt;
	for _, alias in ipairs (aliases_list) do									-- for each alias in the aliases list&lt;br /&gt;
		if alias:match (&amp;#039;#&amp;#039;) then												-- if this alias can be enumerated&lt;br /&gt;
			if &amp;#039;1&amp;#039; == index then												-- when index is 1 test for enumerated and non-enumerated aliases&lt;br /&gt;
				value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);	-- first test for non-enumerated alias&lt;br /&gt;
			end&lt;br /&gt;
			value, selected = is_alias_used (args, alias, index, true, value, selected, error_list);		-- test for enumerated alias&lt;br /&gt;
		else&lt;br /&gt;
			value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);		--test for non-enumerated alias&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if #error_list &amp;gt; 0 and &amp;#039;none&amp;#039; ~= error_condition then						-- for cases where this code is used outside of extract_names()&lt;br /&gt;
		local error_str = &amp;#039;&amp;#039;;&lt;br /&gt;
		for _, k in ipairs (error_list) do&lt;br /&gt;
			if error_str ~= &amp;#039;&amp;#039; then error_str = error_str .. cfg.messages[&amp;#039;parameter-separator&amp;#039;] end&lt;br /&gt;
			error_str = error_str .. wrap_style (&amp;#039;parameter&amp;#039;, k);&lt;br /&gt;
		end&lt;br /&gt;
		if #error_list &amp;gt; 1 then&lt;br /&gt;
			error_str = error_str .. cfg.messages[&amp;#039;parameter-final-separator&amp;#039;];&lt;br /&gt;
		else&lt;br /&gt;
			error_str = error_str .. cfg.messages[&amp;#039;parameter-pair-separator&amp;#039;];&lt;br /&gt;
		end&lt;br /&gt;
		error_str = error_str .. wrap_style (&amp;#039;parameter&amp;#039;, selected);&lt;br /&gt;
		append_error (error_condition, {error_str});&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return value, selected;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; M A K E _ E R R O R _ T A I L &amp;gt;--------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
The function generates error/maintenance-related messages and/or tracking categories from &amp;quot;z&amp;quot; defined in this module.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function make_error_tail (flag)&lt;br /&gt;
	local error_text = &amp;#039;&amp;#039;;&lt;br /&gt;
	if #z.message_tail ~= 0 then&lt;br /&gt;
		error_text = &amp;#039; &amp;#039;;&lt;br /&gt;
		for i,v in ipairs (z.message_tail) do&lt;br /&gt;
			if is_set (v[1]) then&lt;br /&gt;
				if i == #z.message_tail then&lt;br /&gt;
					error_text = error_text .. error_comment (v[1], v[2]);&lt;br /&gt;
				else&lt;br /&gt;
					error_text = error_text .. error_comment (v[1] .. &amp;#039;; &amp;#039;, v[2]);&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if #z.maintenance_cats ~= 0 then&lt;br /&gt;
		local maintenance_text = &amp;#039;&amp;#039;;&lt;br /&gt;
		for _, v in ipairs (z.maintenance_cats) do								-- append maintenance categories&lt;br /&gt;
			maintenance_text = maintenance_text .. substitute (cfg.messages[&amp;#039;maintenance-item&amp;#039;], {v, make_internal_link (&amp;#039;:Category:&amp;#039; .. v, cfg.messages[&amp;#039;maintenance-link&amp;#039;])})&lt;br /&gt;
		end&lt;br /&gt;
		error_text = error_text .. wrap_style (&amp;#039;maintenance&amp;#039;, maintenance_text);&lt;br /&gt;
																				-- maintenance mesages (realy just the names of the categories for now)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if not flag then&lt;br /&gt;
		for _, v in ipairs (z.error_categories) do&lt;br /&gt;
			error_text = error_text .. make_internal_link (&amp;#039;Category:&amp;#039; .. v);&lt;br /&gt;
		end&lt;br /&gt;
		for _, v in ipairs (z.maintenance_cats) do								-- append maintenance categories&lt;br /&gt;
			error_text = error_text .. make_internal_link (&amp;#039;Category:&amp;#039; .. v);&lt;br /&gt;
		end&lt;br /&gt;
		for _, v in ipairs (z.properties_cats) do								-- append maintenance categories&lt;br /&gt;
			error_text = error_text .. make_internal_link (&amp;#039;Category:&amp;#039; .. v);&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return error_text;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; R E S E T _ E R R O R &amp;gt;-------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Reset error/maintenance messages/categories in z.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function reset_error (args)&lt;br /&gt;
	if (in_array (&amp;#039;err_cats&amp;#039;, args)) then&lt;br /&gt;
		z.error_categories = {};&lt;br /&gt;
	end&lt;br /&gt;
	if (in_array (&amp;#039;prop_cats&amp;#039;, args)) then&lt;br /&gt;
		z.properties_cats = {};&lt;br /&gt;
	end&lt;br /&gt;
	if (in_array (&amp;#039;maint_cats&amp;#039;, args)) then&lt;br /&gt;
		z.maintenance_cats = {};&lt;br /&gt;
	end&lt;br /&gt;
	if (in_array (&amp;#039;err_ids&amp;#039;, args)) then&lt;br /&gt;
		z.error_ids = {};&lt;br /&gt;
	end&lt;br /&gt;
	if (in_array (&amp;#039;msg_tail&amp;#039;, args)) then&lt;br /&gt;
		z.message_tail = {};&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; S E T _ S E L E C T E D _ M O D U L E S &amp;gt;--------------------------------------&lt;br /&gt;
&lt;br /&gt;
Sets local cfg table to same (live or sandbox) as that used by the other modules.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function set_selected_modules (cfg_table_ptr, utilities_page_ptr, links_page_ptr)&lt;br /&gt;
	cfg = cfg_table_ptr;&lt;br /&gt;
	&lt;br /&gt;
	in_array = utilities_page_ptr.in_array;&lt;br /&gt;
	is_set = utilities_page_ptr.is_set;&lt;br /&gt;
	substitute = utilities_page_ptr.substitute;&lt;br /&gt;
	wrap_style= utilities_page_ptr.wrap_style;&lt;br /&gt;
	&lt;br /&gt;
	make_internal_link = links_page_ptr.make_internal_link;&lt;br /&gt;
	&lt;br /&gt;
end&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;
	add_maint_cat = add_maint_cat,												-- exported functions&lt;br /&gt;
	add_prop_cat = add_prop_cat,&lt;br /&gt;
	append_error = append_error,&lt;br /&gt;
	make_error_tail = make_error_tail,&lt;br /&gt;
	reset_error = reset_error,&lt;br /&gt;
	select_one = select_one,&lt;br /&gt;
	set_error = set_error,&lt;br /&gt;
	throw_error = throw_error,&lt;br /&gt;
	&lt;br /&gt;
	set_selected_modules = set_selected_modules&lt;br /&gt;
	}&lt;/div&gt;</summary>
		<author><name>Lilauid</name></author>
	</entry>
</feed>