<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.cultopedia.org/index.php?action=history&amp;feed=atom&amp;title=Module%3ACite_Q</id>
	<title>Module:Cite Q - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.cultopedia.org/index.php?action=history&amp;feed=atom&amp;title=Module%3ACite_Q"/>
	<link rel="alternate" type="text/html" href="https://www.cultopedia.org/index.php?title=Module:Cite_Q&amp;action=history"/>
	<updated>2026-04-06T01:34:33Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.5</generator>
	<entry>
		<id>https://www.cultopedia.org/index.php?title=Module:Cite_Q&amp;diff=1547&amp;oldid=prev</id>
		<title>imported&gt;Trappist the monk: synch from sandbox;</title>
		<link rel="alternate" type="text/html" href="https://www.cultopedia.org/index.php?title=Module:Cite_Q&amp;diff=1547&amp;oldid=prev"/>
		<updated>2026-02-01T15:57:31Z</updated>

		<summary type="html">&lt;p&gt;synch from sandbox;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;require(&amp;#039;strict&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
local wdib = require(&amp;#039;Module:WikidataIB&amp;#039;)&lt;br /&gt;
local getValue = wdib._getValue&lt;br /&gt;
local _getPropOfProp = wdib._getPropOfProp&lt;br /&gt;
local followQid = wdib._followQid&lt;br /&gt;
local getPropertyIDs = wdib._getPropertyIDs&lt;br /&gt;
local cite_cfg = mw.loadData (&amp;#039;Module:Cite/config&amp;#039;)&lt;br /&gt;
local cfg = mw.loadData (&amp;#039;Module:Cite_Q/config&amp;#039;)&lt;br /&gt;
local cs1_module = &amp;#039;Module:Citation/CS1&amp;#039;								-- don&amp;#039;t load the module yet, may not be needed&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- makeOrdinal needs to be internationalised along with cfg.i18n_t&lt;br /&gt;
-- takes cardinal number as a numeric and returns the ordinal as a string&lt;br /&gt;
-- we need three exceptions in English for 1st, 2nd, 3rd, 21st, .. 31st, etc.&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
local makeOrdinal = function(cardinal)&lt;br /&gt;
	local card = tonumber(cardinal)&lt;br /&gt;
	if not card then return cardinal end&lt;br /&gt;
	local ordsuffix = cfg.i18n_t.ordinal.default&lt;br /&gt;
	if card % 10 == 1 then&lt;br /&gt;
		ordsuffix = cfg.i18n_t.ordinal[1]&lt;br /&gt;
	elseif card % 10 == 2 then&lt;br /&gt;
		ordsuffix = cfg.i18n_t.ordinal[2]&lt;br /&gt;
	elseif card % 10 == 3 then&lt;br /&gt;
		ordsuffix = cfg.i18n_t.ordinal[3]&lt;br /&gt;
	end&lt;br /&gt;
	-- In English, 1, 21, 31, etc. use &amp;#039;st&amp;#039;, but 11, 111, etc. use &amp;#039;th&amp;#039;&lt;br /&gt;
	-- similarly for 12 and 13, etc.&lt;br /&gt;
	if (card % 100 == 11) or (card % 100 == 12) or (card % 100 == 13) then&lt;br /&gt;
		ordsuffix = cfg.i18n_t.ordinal.default&lt;br /&gt;
	end&lt;br /&gt;
	return card .. ordsuffix&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; I S _ S E T &amp;gt;--------------------------------------------------------------&lt;br /&gt;
Returns true if argument is set; false otherwise. Argument is &amp;#039;set&amp;#039; when it exists (not nil) or when it is not an empty string.&lt;br /&gt;
]]&lt;br /&gt;
local function is_set( var )&lt;br /&gt;
	return not (var == nil or var == &amp;#039;&amp;#039;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; I N _ A R R A Y &amp;gt;--------------------------------------------------------------&lt;br /&gt;
Whether needle is in haystack (taken from Module:Citation/CS1/Utilities)&lt;br /&gt;
]]&lt;br /&gt;
local function in_array( needle, haystack )&lt;br /&gt;
	if needle == nil then&lt;br /&gt;
		return false&lt;br /&gt;
	end&lt;br /&gt;
	for n, v in ipairs( haystack ) do&lt;br /&gt;
		if v == needle then&lt;br /&gt;
			return n&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return false&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; A C C E P T _ V A L U E &amp;gt;-------------------------------------------------------&lt;br /&gt;
Accept WD value by framing in ((...)) if param_val is equal to keyword; else pass-through WD value as is.&lt;br /&gt;
]]&lt;br /&gt;
local function accept_value( param_val, wd_val )&lt;br /&gt;
	local val = param_val&lt;br /&gt;
&lt;br /&gt;
	if val then&lt;br /&gt;
		if in_array (val, {&amp;#039;accept&amp;#039;, &amp;#039;))((&amp;#039;, &amp;#039;:d:&amp;#039;}) then&lt;br /&gt;
			val = &amp;#039;((&amp;#039; .. wd_val .. &amp;#039;))&amp;#039;&lt;br /&gt;
		elseif &amp;#039;((accept))&amp;#039; == val then&lt;br /&gt;
			val = &amp;#039;accept&amp;#039;&lt;br /&gt;
		elseif &amp;#039;(())(())&amp;#039; == val then&lt;br /&gt;
			val = &amp;#039;))((&amp;#039;&lt;br /&gt;
		elseif &amp;#039;((:d:))&amp;#039; == val then&lt;br /&gt;
			val = &amp;#039;:d:&amp;#039;&lt;br /&gt;
		else&lt;br /&gt;
			val = wd_val&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return val&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- function to fetch a value to display&lt;br /&gt;
local function makelink(v, out, link, maxpos, wdl)&lt;br /&gt;
	local label&lt;br /&gt;
	if v.mainsnak.snaktype == &amp;quot;value&amp;quot; then&lt;br /&gt;
		if v.mainsnak.datatype == &amp;quot;wikibase-item&amp;quot; then&lt;br /&gt;
			local qnumber = v.mainsnak.datavalue.value.id&lt;br /&gt;
			local sitelink = mw.wikibase.getSitelink(qnumber)&lt;br /&gt;
			if qnumber == &amp;quot;Q2818964&amp;quot; then sitelink = nil end -- suppress link to &amp;quot;Various authors&amp;quot;&lt;br /&gt;
			if v.qualifiers and v.qualifiers.P1932 then&lt;br /&gt;
				label = v.qualifiers.P1932[1].datavalue.value&lt;br /&gt;
			else&lt;br /&gt;
				label = mw.wikibase.getLabel(qnumber)&lt;br /&gt;
				if label then&lt;br /&gt;
					label = mw.text.nowiki(label)&lt;br /&gt;
				else&lt;br /&gt;
					label = qnumber -- should add tracking category&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			local position = maxpos + 1 -- Default to &amp;#039;next&amp;#039; author.&lt;br /&gt;
			-- use P1545 (series ordinal) instead of default position.&lt;br /&gt;
			if v[&amp;quot;qualifiers&amp;quot;] and v.qualifiers[&amp;quot;P1545&amp;quot;] and v.qualifiers[&amp;quot;P1545&amp;quot;][1] then&lt;br /&gt;
				position = tonumber(v.qualifiers[&amp;quot;P1545&amp;quot;][1].datavalue.value)&lt;br /&gt;
			end&lt;br /&gt;
			maxpos = math.max(maxpos, position)&lt;br /&gt;
			if sitelink then&lt;br /&gt;
				-- just the plain name,&lt;br /&gt;
				-- but keep a record of the links, using the same index&lt;br /&gt;
				out[position] = label&lt;br /&gt;
				link[position] = sitelink&lt;br /&gt;
			else&lt;br /&gt;
				if wdl then&lt;br /&gt;
					-- show that there&amp;#039;s a Wikidata entry available&lt;br /&gt;
					out[position] = string.format(&lt;br /&gt;
						&amp;quot;[[:d:Q%s|%s]]&amp;amp;nbsp;&amp;lt;span title=&amp;#039;%s&amp;#039;&amp;gt;[[File:Wikidata-logo.svg|16px|alt=|link=]]&amp;lt;/span&amp;gt;&amp;quot;,&lt;br /&gt;
						v.mainsnak.datavalue.value[&amp;quot;numeric-id&amp;quot;],&lt;br /&gt;
						label,&lt;br /&gt;
						cfg.i18n_t[&amp;quot;errors&amp;quot;][&amp;quot;local-article-not-found&amp;quot;]&lt;br /&gt;
					)&lt;br /&gt;
				else&lt;br /&gt;
					-- no Wikidata links wanted, so just give the plain label&lt;br /&gt;
					out[position] = label&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		elseif v.mainsnak.datatype == &amp;quot;string&amp;quot; then&lt;br /&gt;
			local position = maxpos + 1 -- Default to &amp;#039;next&amp;#039; author.&lt;br /&gt;
			-- use P1545 (series ordinal) instead of default position.&lt;br /&gt;
			if v[&amp;quot;qualifiers&amp;quot;] and v.qualifiers[&amp;quot;P1545&amp;quot;] and v.qualifiers[&amp;quot;P1545&amp;quot;][1] then&lt;br /&gt;
				position = tonumber(v.qualifiers[&amp;quot;P1545&amp;quot;][1].datavalue.value)&lt;br /&gt;
			end&lt;br /&gt;
			maxpos = math.max(maxpos, position)&lt;br /&gt;
			out[position] = v.mainsnak.datavalue.value&lt;br /&gt;
		else&lt;br /&gt;
			-- not a wikibase-item or a string!&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		-- code here if we want to return something when author is &amp;quot;unknown&amp;quot;&lt;br /&gt;
		if v.qualifiers and v.qualifiers.P1932 then&lt;br /&gt;
			label = v.qualifiers.P1932[1].datavalue.value&lt;br /&gt;
		else&lt;br /&gt;
			label = cfg.i18n_t[&amp;quot;unknown-author&amp;quot;] .. (cfg.i18n_t.trackingcats[&amp;quot;unknown-author&amp;quot;] or &amp;quot;&amp;quot;)&lt;br /&gt;
		end&lt;br /&gt;
		maxpos = maxpos + 1&lt;br /&gt;
		out[maxpos] = label&lt;br /&gt;
	end&lt;br /&gt;
	return maxpos&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[=[-------------------------&amp;lt; G E T _ N A M E _ L I S T &amp;gt;----------------------------------------------------&lt;br /&gt;
get_name_list -- adapted from getAuthors code taken from Module:RexxS&lt;br /&gt;
arguments:&lt;br /&gt;
	nl_type - type of name list to fetch: nl_type = &amp;#039;author&amp;#039; for authors; &amp;#039;editor&amp;#039; for editors; &amp;#039;translator&amp;#039; for translators&lt;br /&gt;
	args - pointer to the parameter arguments table from the template call&lt;br /&gt;
	qid - value from |qid= parameter; the Q-id of the source (book, etc.) in qid&lt;br /&gt;
	wdl - value from the |wdl= parameter; a Boolean passed to enable links to Wikidata when no article exists&lt;br /&gt;
returns nothing; modifies the args table&lt;br /&gt;
]=]&lt;br /&gt;
&lt;br /&gt;
local function get_name_list (nl_type, args, qid, wdl)&lt;br /&gt;
	local propertyID = &amp;quot;P50&amp;quot;&lt;br /&gt;
	local fallbackID = &amp;quot;P2093&amp;quot; -- author name string&lt;br /&gt;
&lt;br /&gt;
	if nl_type ==&amp;quot;author&amp;quot; then&lt;br /&gt;
		propertyID = &amp;#039;P50&amp;#039;		-- for authors&lt;br /&gt;
		fallbackID = &amp;#039;P2093&amp;#039;	-- author-string&lt;br /&gt;
	elseif nl_type ==&amp;quot;editor&amp;quot; then&lt;br /&gt;
		propertyID = &amp;#039;P5769&amp;#039;	-- &amp;quot;editor-in-chief&amp;quot;&lt;br /&gt;
		fallbackID = &amp;#039;P98&amp;#039;		-- for editors - So-called &amp;quot;fallbacks&amp;quot; are actually a second set of properties processed&lt;br /&gt;
		-- TBD. Take book series editors into account as well (if they have a separate P code as well)?&lt;br /&gt;
	elseif nl_type == &amp;quot;translator&amp;quot; then&lt;br /&gt;
		propertyID = &amp;#039;P655&amp;#039;		-- for translators&lt;br /&gt;
		fallbackID = nil&lt;br /&gt;
--	elseif &amp;#039;contributor&amp;#039; == nl_type then&lt;br /&gt;
--		f.e. author of forewords (P2679) and afterwords (P2680); requires |contribution=, |title= and |author=&lt;br /&gt;
--		propertyID = &amp;#039;P&amp;#039;		-- for contributors&lt;br /&gt;
--		fallbackID = nil&lt;br /&gt;
	else&lt;br /&gt;
		return					-- not specified so return&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- wdl is a Boolean passed to enable links to Wikidata when no article exists&lt;br /&gt;
	-- if &amp;quot;false&amp;quot; or &amp;quot;no&amp;quot; or &amp;quot;0&amp;quot; is passed set it false&lt;br /&gt;
	-- if nothing or an empty string is passed set it false&lt;br /&gt;
	if wdl and (#wdl &amp;gt; 0) then&lt;br /&gt;
		wdl = wdl:lower()&lt;br /&gt;
		wdl = in_array (wdl, {&amp;quot;false&amp;quot;, &amp;quot;no&amp;quot;, &amp;quot;0&amp;quot;})&lt;br /&gt;
	else&lt;br /&gt;
		-- wdl is empty, so&lt;br /&gt;
		wdl = false&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local props = nil&lt;br /&gt;
	local fallback = nil&lt;br /&gt;
	if mw.wikibase.entityExists(qid) then&lt;br /&gt;
		props = mw.wikibase.getAllStatements(qid, propertyID)&lt;br /&gt;
		if props and fallbackID then&lt;br /&gt;
			fallback = mw.wikibase.getAllStatements(qid, fallbackID)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Make sure it actually has at least one of the properties requested&lt;br /&gt;
	if not (props and props[1]) and not (fallback and fallback[1]) then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- So now we have something to return:&lt;br /&gt;
	-- table &amp;#039;out&amp;#039; is going to store the names(s):&lt;br /&gt;
	-- and table &amp;#039;link&amp;#039; will store any links to the name&amp;#039;s article&lt;br /&gt;
	local out = {}&lt;br /&gt;
	local link = {}&lt;br /&gt;
	local maxpos = 0&lt;br /&gt;
	if props and props[1] then&lt;br /&gt;
		for k, v in pairs(props) do&lt;br /&gt;
			maxpos = makelink(v, out, link, maxpos, wdl)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if fallback and fallback[1] then&lt;br /&gt;
		-- second properties&lt;br /&gt;
		for k, v in pairs(fallback) do&lt;br /&gt;
			maxpos = makelink(v, out, link, maxpos, wdl)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- if there&amp;#039;s anything to return, then insert the additions in the template arguments table&lt;br /&gt;
	-- in the form |author1=firstname secondname |author2= ...&lt;br /&gt;
	-- Renumber, in case we have inconsistent numbering&lt;br /&gt;
	local keys = {}&lt;br /&gt;
	for k, v in pairs(out) do&lt;br /&gt;
		keys[#keys + 1] = k&lt;br /&gt;
	end&lt;br /&gt;
	table.sort(keys) -- as they might be out of order&lt;br /&gt;
	for i, k in ipairs(keys) do&lt;br /&gt;
		out[k] = out[k]:gsub (&amp;#039;&amp;amp;#39;&amp;#039;, &amp;#039;\&amp;#039;&amp;#039;);									-- prevent cs1|2 multiple names categorization; replace html entity with the actual character&lt;br /&gt;
		mw.log(i .. &amp;quot; &amp;quot; .. k .. &amp;quot; &amp;quot; .. (out[k]))&lt;br /&gt;
		if args[nl_type .. i] then -- name gets overwritten&lt;br /&gt;
			-- pull corresponding -link only if overwritten name is same as WD name&lt;br /&gt;
			if link[k] and (args[nl_type .. i] == out[k]) then&lt;br /&gt;
				args[nl_type .. &amp;#039;-link&amp;#039; .. i] = args[nl_type .. &amp;#039;-link&amp;#039; .. i] or link[k] -- author-linkn or editor-linkn&lt;br /&gt;
			end&lt;br /&gt;
		else -- name does not get overwritten, so pull name from WD&lt;br /&gt;
			args[nl_type .. i] = out[k]&lt;br /&gt;
			if link[k] then&lt;br /&gt;
				args[nl_type .. &amp;#039;-link&amp;#039; .. i] = args[nl_type .. &amp;#039;-link&amp;#039; .. i] or link[k] -- author-linkn or editor-linkn&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- gets language codes used for a monolingual text property as a table&lt;br /&gt;
local function _getLangOfProp(qid, pid)&lt;br /&gt;
	if not pid then return {} end&lt;br /&gt;
	local out = {}&lt;br /&gt;
	local props = mw.wikibase.getAllStatements(qid, pid)&lt;br /&gt;
	for i, v in ipairs(props) do&lt;br /&gt;
		if v.mainsnak.datatype == &amp;quot;monolingualtext&amp;quot; and v.mainsnak.datavalue then&lt;br /&gt;
			out[#out + 1] = v.mainsnak.datavalue.value.language&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return out&lt;br /&gt;
end&lt;br /&gt;
local function getLangOfProp(frame)&lt;br /&gt;
	local pid = frame.args.pid or mw.text.trim(frame.args[1] or &amp;quot;&amp;quot;)&lt;br /&gt;
	if pid == &amp;quot;&amp;quot; then return end&lt;br /&gt;
	local qid = frame.args.qid&lt;br /&gt;
	if qid == &amp;quot;&amp;quot; then qid = nil end&lt;br /&gt;
	return table.concat(_getLangOfProp(qid, pid), &amp;quot;, &amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- gets the language codes of a Wikidata entry as a table&lt;br /&gt;
local function _lang_code(qid)&lt;br /&gt;
	local lc = _getPropOfProp( {qid = qid, prop1 = &amp;quot;P407&amp;quot;, prop2 = &amp;quot;P424&amp;quot;, ps = 1} )&lt;br /&gt;
	if lc then return mw.text.split( lc, &amp;quot;[, ]+&amp;quot; ) end&lt;br /&gt;
	lc = _getPropOfProp( {qid = qid, prop1 = &amp;quot;P407&amp;quot;, prop2 = &amp;quot;P218&amp;quot;, ps = 1} )&lt;br /&gt;
	if lc then return mw.text.split( lc, &amp;quot;[, ]+&amp;quot; ) end&lt;br /&gt;
	return _getLangOfProp(qid, &amp;quot;P1476&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
local function lang_code(frame)&lt;br /&gt;
	return table.concat(_lang_code(frame.args.qid or mw.text.trim(frame.args[1] or &amp;quot;&amp;quot;)), &amp;quot;, &amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- export for debug&lt;br /&gt;
local function getPropOfProp(frame)&lt;br /&gt;
	return _getPropOfProp(frame.args)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- wraps a string in nowiki unless disable flag is set&lt;br /&gt;
local function wrap_nowiki(str, disable)&lt;br /&gt;
	if disable then return str or &amp;#039;&amp;#039; end&lt;br /&gt;
	return mw.text.nowiki(str or &amp;#039;&amp;#039;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- sort sequence table whose values are key-value pairs by key&lt;br /&gt;
local function comp_key(a, b)&lt;br /&gt;
	local param_a, enum_a = a[1]:match (&amp;#039;(%D+)(%d+)$&amp;#039;);							-- get param name and enumerator from &amp;lt;a&amp;gt;&lt;br /&gt;
	local param_b, enum_b = b[1]:match (&amp;#039;(%D+)(%d+)$&amp;#039;);							-- get param name and enumerator from &amp;lt;b&amp;gt;&lt;br /&gt;
	&lt;br /&gt;
	if enum_a and enum_b then													-- if both parameters have neumerators&lt;br /&gt;
		if param_a == param_b then												-- are parameter names the same?&lt;br /&gt;
			return tonumber (enum_a) &amp;lt; tonumber (enum_b);						-- yes: compare enumerators&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return a[1] &amp;lt; b[1];															-- alpha sort if here&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- sort sequence table whose values are key-value pairs by value&lt;br /&gt;
local function comp_val(a, b)&lt;br /&gt;
	return a[2] &amp;lt; b[2]&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[-------------------------&amp;lt; C I T E _ Q &amp;gt;------------------------------------------------------------------&lt;br /&gt;
Takes standard CS1|2 template parameters and passes all to {{citation}}.  If neither of |author= and |author1=&lt;br /&gt;
are set, calls get_authors() to try to get an author name-list from Wikidata.  The result is passed to&lt;br /&gt;
{{citation}} for rendering.&lt;br /&gt;
--]]&lt;br /&gt;
local function _cite_q (citeq_args)&lt;br /&gt;
	local frame = mw.getCurrentFrame()&lt;br /&gt;
&lt;br /&gt;
	-- parameters that don&amp;#039;t get passed to Citation&lt;br /&gt;
	local expand = citeq_args.expand -- when set to anything, causes {{cite q}} to render &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{citation|...}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
	local qid = citeq_args.qid or citeq_args[1]&lt;br /&gt;
	local wdl = citeq_args.wdl&lt;br /&gt;
	local template = citeq_args.template&lt;br /&gt;
	citeq_args.expand = nil&lt;br /&gt;
	citeq_args[1] = nil&lt;br /&gt;
	citeq_args.qid = nil&lt;br /&gt;
	citeq_args.wdl = nil&lt;br /&gt;
	citeq_args.template = nil&lt;br /&gt;
&lt;br /&gt;
	-- if title supplied, flag to not read html title&lt;br /&gt;
	local titleforced = (citeq_args.title ~= nil)&lt;br /&gt;
&lt;br /&gt;
	local oth = {}&lt;br /&gt;
&lt;br /&gt;
	-- put the language codes into a sequential table langcodes[]&lt;br /&gt;
	local langcodes = {}&lt;br /&gt;
	if citeq_args.language then&lt;br /&gt;
		-- check these are a supported language codes&lt;br /&gt;
		for lc in mw.text.gsplit( citeq_args.language, &amp;quot;[, ]+&amp;quot;, false ) do&lt;br /&gt;
			langcodes[#langcodes+1] = mw.language.isSupportedLanguage(citeq_args.language) and citeq_args.language&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if not langcodes[1] then&lt;br /&gt;
		-- try to find language of work&lt;br /&gt;
		langcodes = _lang_code(qid)&lt;br /&gt;
	end&lt;br /&gt;
	if not langcodes[1] then&lt;br /&gt;
		-- try fallback to journal&amp;#039;s language&lt;br /&gt;
		local journal_qid = followQid({qid = qid, props = &amp;quot;P1433&amp;quot;})&lt;br /&gt;
		langcodes = journal_qid and _lang_code(journal_qid)&lt;br /&gt;
	end&lt;br /&gt;
	citeq_args.language = citeq_args.language or table.concat(langcodes, &amp;quot;, &amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	-- loop through list of simple properties and get their values in citeq_args&lt;br /&gt;
	for name, data in pairs(cfg.simple_properties_t) do&lt;br /&gt;
		citeq_args[name] = getValue( {data.id, fwd = &amp;quot;ALL&amp;quot;, osd = &amp;quot;no&amp;quot;, noicon = &amp;quot;true&amp;quot;, qid = qid, maxvals = data.maxvals, linked = data.linked, rank = data.rank or &amp;quot;best&amp;quot;, citeq_args[name] } )&lt;br /&gt;
		if data.populate_from_journal then&lt;br /&gt;
			local publishedin = getValue( {&amp;quot;P1433&amp;quot;, ps = 1, qid = qid, maxvals = 0, citeq_args[name], qual = data.id, qualsonly = &amp;#039;yes&amp;#039;} )&lt;br /&gt;
			citeq_args[name] = publishedin or _getPropOfProp({qid = qid, prop1 = &amp;quot;P1433&amp;quot;, prop2 = data.id, maxvals = data.maxvals, ps = 1})&lt;br /&gt;
		end&lt;br /&gt;
		if citeq_args[name] and citeq_args[name]:find (cfg.i18n_t.trackingcats[&amp;quot;missing-wikidata&amp;quot;], 1, true) then&lt;br /&gt;
			-- try fallback to work&amp;#039;s native language&lt;br /&gt;
			citeq_args[name] = getValue( {data.id, ps = 1, qid = qid, maxvals = data.maxvals, linked = &amp;quot;no&amp;quot;, lang = langcodes[1] } )&lt;br /&gt;
			if citeq_args[name]:find(&amp;#039;^Q%d+$&amp;#039;) then -- qid was returned&lt;br /&gt;
				-- try fallback to qid&amp;#039;s native language&lt;br /&gt;
				local qid_languages = _lang_code(citeq_args[name])&lt;br /&gt;
				citeq_args[name] = getValue( {data.id, ps = 1, qid = qid, maxvals = data.maxvals, linked = &amp;quot;no&amp;quot;, lang = qid_languages[1] } )&lt;br /&gt;
				if citeq_args[name]:find(&amp;#039;^Q%d+$&amp;#039;) then -- qid was returned again&lt;br /&gt;
					citeq_args[name] = nil&lt;br /&gt;
				else&lt;br /&gt;
					-- record the language found if no lang specified&lt;br /&gt;
					citeq_args.language = citeq_args.language or qid_languages[1]&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		if data.others then&lt;br /&gt;
			oth[#oth + 1] = citeq_args[name] and (name:gsub(&amp;quot;^%l&amp;quot;, string.upper) .. &amp;quot;: &amp;quot; .. citeq_args[name])&lt;br /&gt;
			citeq_args[name] = nil&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	citeq_args.others = citeq_args.others or table.concat(oth, &amp;quot;. &amp;quot;)&lt;br /&gt;
	if citeq_args.others == &amp;quot;&amp;quot; then&lt;br /&gt;
		citeq_args.others = nil&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	citeq_args.journal = citeq_args.journal and citeq_args.journal:gsub(&amp;quot;^&amp;#039;&amp;#039;&amp;quot;, &amp;quot;&amp;quot;):gsub(&amp;quot;&amp;#039;&amp;#039;$&amp;quot;, &amp;quot;&amp;quot;):gsub(&amp;quot;|&amp;#039;&amp;#039;&amp;quot;, &amp;quot;|&amp;quot;):gsub(&amp;quot;&amp;#039;&amp;#039;]]&amp;quot;, &amp;quot;]]&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	citeq_args.ol = (getValue( {&amp;quot;P648&amp;quot;, ps = 1, qid = qid, maxvals = 1, citeq_args.ol } ) or &amp;#039;&amp;#039;):gsub(&amp;quot;^OL(.+)$&amp;quot;, &amp;quot;%1&amp;quot;)&lt;br /&gt;
	if citeq_args.ol == &amp;quot;&amp;quot; then&lt;br /&gt;
		citeq_args.ol = nil&lt;br /&gt;
	end&lt;br /&gt;
	-- TBD. Take care of |ol-access=?&lt;br /&gt;
&lt;br /&gt;
	citeq_args.biorxiv = citeq_args.biorxiv and (&amp;quot;10.1101/&amp;quot; .. citeq_args.biorxiv)&lt;br /&gt;
&lt;br /&gt;
	citeq_args.isbn = getValue( {&amp;quot;P957&amp;quot;, ps = 1, qid = qid, maxvals = 1, rank=&amp;quot;best&amp;quot;, citeq_args.isbn } ) -- try ISBN 10 (only one value accepted)&lt;br /&gt;
&lt;br /&gt;
	-- if url then see if there&amp;#039;s an archive: citeq_args.url&lt;br /&gt;
	local url&lt;br /&gt;
	if not citeq_args.url then&lt;br /&gt;
		for i, pr in ipairs( {&amp;quot;P953&amp;quot;, &amp;quot;P856&amp;quot;, &amp;quot;P2699&amp;quot;} ) do&lt;br /&gt;
			url = getValue( {pr, ps = 1, qid = qid, maxvals = 1, qual=&amp;quot;P1065&amp;quot; } )&lt;br /&gt;
			if url then&lt;br /&gt;
				citeq_args.url = mw.text.split( url, &amp;quot; (&amp;quot;, true )[1]&lt;br /&gt;
				local arcurl = mw.ustring.match( url, &amp;quot; %((.*)%)&amp;quot; )				-- when there is an archive url, &amp;lt;url&amp;gt; holds: url&amp;lt;space&amp;gt;(archive url); here extract the archive url if present&lt;br /&gt;
				if arcurl then&lt;br /&gt;
					local arcy, arcm, arcd = arcurl:match(&amp;quot;(20%d%d)%p?(%d%d)%p?(%d%d)&amp;quot;)&lt;br /&gt;
					if arcy and arcm and arcd then&lt;br /&gt;
						citeq_args[&amp;quot;archive-url&amp;quot;] = arcurl&lt;br /&gt;
						citeq_args[&amp;quot;archive-date&amp;quot;] = tonumber(arcd) .. &amp;quot; &amp;quot; .. cfg.i18n_t.months[tonumber(arcm)] .. &amp;quot; &amp;quot; .. arcy&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
				break&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if citeq_args.publisher == &amp;quot;Unknown&amp;quot; then -- look for &amp;quot;stated as&amp;quot; (P1932)&lt;br /&gt;
		local stated_as = getValue( {&amp;quot;P123&amp;quot;, ps = 1, qid = qid, maxvals = 1, qual=&amp;quot;P1932&amp;quot;, qo=&amp;quot;y&amp;quot;} )&lt;br /&gt;
		if stated_as then citeq_args.publisher = stated_as end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if not titleforced then&lt;br /&gt;
		-- Handle subtitle.&lt;br /&gt;
		if citeq_args.title then&lt;br /&gt;
			local subtitle = mw.wikibase.getBestStatements (qid, &amp;#039;P1680&amp;#039;);&lt;br /&gt;
			if 0 ~= #subtitle then&lt;br /&gt;
				subtitle = subtitle[1].mainsnak.datavalue.value.text;&lt;br /&gt;
				citeq_args.title = citeq_args.title .. &amp;quot;: &amp;quot; .. subtitle&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		local htmltitle = getValue( {&amp;quot;P1476&amp;quot;, qual = &amp;quot;P6833&amp;quot;, ps = 1, qid = qid, maxvals = 1, qo = &amp;quot;y&amp;quot;} )&lt;br /&gt;
		if htmltitle then&lt;br /&gt;
			citeq_args.title = htmltitle:gsub(&amp;quot;&amp;lt;/?i&amp;gt;&amp;quot;, &amp;quot;&amp;#039;&amp;#039;&amp;quot;)&lt;br /&gt;
		else&lt;br /&gt;
			local title_display = citeq_args.title&lt;br /&gt;
				or mw.wikibase.getLabel(qid)&lt;br /&gt;
				or (langcodes[1] and mw.wikibase.getLabelByLang(qid, langcodes[1]))&lt;br /&gt;
			if citeq_args.url then&lt;br /&gt;
				citeq_args.title = wrap_nowiki(title_display)&lt;br /&gt;
			else&lt;br /&gt;
				local slink = mw.wikibase.getSitelink(qid)&lt;br /&gt;
				local slink_flag = false&lt;br /&gt;
				local wrap_title = &amp;#039;&amp;#039;&lt;br /&gt;
				local wslink = false&lt;br /&gt;
				if not slink then&lt;br /&gt;
					-- See if we have wikisource&lt;br /&gt;
					if not citeq_args.url then&lt;br /&gt;
						local wikisource_sitelink = mw.wikibase.getSitelink(qid, cfg.i18n_t.wikisource) or nil&lt;br /&gt;
						if wikisource_sitelink then&lt;br /&gt;
							slink = &amp;#039;:s:&amp;#039;..wikisource_sitelink&lt;br /&gt;
							wslink = true&lt;br /&gt;
						end&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
				if citeq_args.title then&lt;br /&gt;
					if slink then&lt;br /&gt;
						wrap_title = wrap_nowiki(citeq_args.title)&lt;br /&gt;
						slink_flag = true&lt;br /&gt;
					else&lt;br /&gt;
						citeq_args.title = wrap_nowiki(citeq_args.title)&lt;br /&gt;
					end&lt;br /&gt;
				else&lt;br /&gt;
					if slink and not wslink then&lt;br /&gt;
						if slink:lower() == title_display:lower() then&lt;br /&gt;
							citeq_args.title = &amp;#039;[[&amp;#039; .. slink .. &amp;#039;]]&amp;#039;&lt;br /&gt;
						else&lt;br /&gt;
							wrap_title = wrap_nowiki(slink:gsub(&amp;quot;%s%(.+%)$&amp;quot;, &amp;quot;&amp;quot;):gsub(&amp;quot;,.+$&amp;quot;, &amp;quot;&amp;quot;))&lt;br /&gt;
							slink_flag = true&lt;br /&gt;
						end&lt;br /&gt;
					elseif wslink then&lt;br /&gt;
						wrap_title = wrap_nowiki(title_display)&lt;br /&gt;
						slink_flag = true&lt;br /&gt;
					else&lt;br /&gt;
						citeq_args.title = wrap_nowiki(title_display)&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
				if slink_flag then&lt;br /&gt;
					if slink == wrap_title and not wslink then -- direct link&lt;br /&gt;
						citeq_args.title = &amp;#039;[[&amp;#039; .. slink .. &amp;#039;]]&amp;#039;&lt;br /&gt;
					else -- piped link&lt;br /&gt;
						citeq_args.title = &amp;#039;[[&amp;#039; .. slink .. &amp;#039;|&amp;#039; .. wrap_title .. &amp;#039;]]&amp;#039;&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- TBD: incorporate |at, |sheets= and |sheet= here as well&lt;br /&gt;
	-- Sort out what should happen if several of them are given at the same time&lt;br /&gt;
	if citeq_args.page or citeq_args.p then -- let single take precedence over multiple&lt;br /&gt;
		citeq_args.pages = nil&lt;br /&gt;
		citeq_args.pp = nil&lt;br /&gt;
	end&lt;br /&gt;
	if citeq_args.pages then&lt;br /&gt;
		local _, count = string.gsub(citeq_args.pages, &amp;quot;[,;%s]%d+&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
		if count == 1 then&lt;br /&gt;
			citeq_args.page = citeq_args.pages&lt;br /&gt;
			citeq_args.pages = nil&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if is_set (qid) then&lt;br /&gt;
		if not is_set (citeq_args.author) and not is_set (citeq_args.author1)&lt;br /&gt;
			and not is_set (citeq_args.subject) and not is_set (citeq_args.subject1)&lt;br /&gt;
			and not is_set (citeq_args.host) and not is_set (citeq_args.host1)&lt;br /&gt;
			and not is_set (citeq_args.last) and not is_set (citeq_args.last1)&lt;br /&gt;
			and not is_set (citeq_args.surname) and not is_set (citeq_args.surname1)&lt;br /&gt;
			and not is_set (citeq_args[&amp;#039;author-last&amp;#039;]) and not is_set (citeq_args[&amp;#039;author-last1&amp;#039;]) and not is_set (citeq_args[&amp;#039;author1-last&amp;#039;])&lt;br /&gt;
			and not is_set (citeq_args[&amp;#039;author-surname&amp;#039;]) and not is_set (citeq_args[&amp;#039;author-surname1&amp;#039;]) and not is_set (citeq_args[&amp;#039;author1-surname1&amp;#039;]) then	-- if neither are set, try to get authors from Wikidata&lt;br /&gt;
			get_name_list (&amp;#039;author&amp;#039;, citeq_args, qid, wdl)				-- modify citeq_args table with authors from Wikidata&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		if not is_set (citeq_args.editor) and not is_set (citeq_args.editor1)&lt;br /&gt;
			and not is_set (citeq_args[&amp;#039;editor-last&amp;#039;]) and not is_set (citeq_args[&amp;#039;editor-last1&amp;#039;]) and not is_set (citeq_args[&amp;#039;editor1-last&amp;#039;])&lt;br /&gt;
			and not is_set (citeq_args[&amp;#039;editor-surname&amp;#039;]) and not is_set (citeq_args[&amp;#039;editor-surname1&amp;#039;]) and not is_set (citeq_args[&amp;#039;editor1-surname&amp;#039;]) then	-- if neither are set, try to get editors from Wikidata&lt;br /&gt;
			get_name_list (&amp;#039;editor&amp;#039;, citeq_args, qid, wdl)				-- modify citeq_args table with editors from Wikidata&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		if not is_set (citeq_args.translator) and not is_set (citeq_args.translator1)&lt;br /&gt;
			and not is_set (citeq_args[&amp;#039;translator-last&amp;#039;]) and not is_set (citeq_args[&amp;#039;translator-last1&amp;#039;]) and not is_set (citeq_args[&amp;#039;translator1-last&amp;#039;])&lt;br /&gt;
			and not is_set (citeq_args[&amp;#039;translator-surname&amp;#039;]) and not is_set (citeq_args[&amp;#039;translator-surname1&amp;#039;]) and not is_set (citeq_args[&amp;#039;translator1-surname&amp;#039;]) then	-- if neither are set, try to get translators from Wikidata&lt;br /&gt;
			get_name_list (&amp;#039;translator&amp;#039;, citeq_args, qid, wdl)			-- modify citeq_args table with translators from Wikidata&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	for k, v in pairs(citeq_args) do&lt;br /&gt;
		if in_array (v, {&amp;#039;(())&amp;#039;, &amp;#039;unset&amp;#039;, &amp;#039;ignore&amp;#039;}) or &amp;#039;string&amp;#039; ~= type(k) then -- empty accept-as-is-written (()) markup to indicate an empty/unused parameter value, other ((...)) markups are deliberately passed down to {{citation}}&lt;br /&gt;
			citeq_args[k] = nil&lt;br /&gt;
		elseif in_array (v, {&amp;#039;((unset))&amp;#039;, &amp;#039;((ignore))&amp;#039;}) then -- strip off markup for free-text values clashing with local keywords&lt;br /&gt;
			citeq_args[k] = &amp;#039;unset&amp;#039;&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local author_count = 0&lt;br /&gt;
	for k, v in pairs(citeq_args) do&lt;br /&gt;
		if k:find(&amp;quot;^author%d+$&amp;quot;) then&lt;br /&gt;
			author_count = author_count + 1&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if author_count &amp;gt; 8 then -- convention in astronomy journals, optional mode for this?&lt;br /&gt;
		if &amp;#039;all&amp;#039; == citeq_args[&amp;#039;display-authors&amp;#039;] then&lt;br /&gt;
			citeq_args[&amp;#039;display-authors&amp;#039;] = nil;								-- unset because no longer needed&lt;br /&gt;
		else&lt;br /&gt;
			citeq_args[&amp;#039;display-authors&amp;#039;] = citeq_args[&amp;#039;display-authors&amp;#039;] or 3	-- limit to three displayed names&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local editor_count = 0&lt;br /&gt;
	for k, v in pairs(citeq_args) do&lt;br /&gt;
		if k:find(&amp;quot;^editor%d+$&amp;quot;) then&lt;br /&gt;
			editor_count = editor_count + 1&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if editor_count &amp;gt; 8 then -- convention in astronomy journals, optional mode for this?&lt;br /&gt;
		if &amp;#039;all&amp;#039; == citeq_args[&amp;#039;display-editors&amp;#039;] then&lt;br /&gt;
			citeq_args[&amp;#039;display-editors&amp;#039;] = nil;								-- unset because no longer needed&lt;br /&gt;
		else&lt;br /&gt;
			citeq_args[&amp;#039;display-editors&amp;#039;] = citeq_args[&amp;#039;display-editors&amp;#039;] or 3	-- limit to three displayed names&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- change edition to ordinal if it&amp;#039;s set and numeric&lt;br /&gt;
	citeq_args.edition = citeq_args.edition and makeOrdinal(citeq_args.edition)&lt;br /&gt;
&lt;br /&gt;
	-- code to make a guess what template to use from the supplied parameters&lt;br /&gt;
	-- (first draft for proof-of-concept)&lt;br /&gt;
	if citeq_args.isbn then&lt;br /&gt;
		template = template or &amp;quot;book&amp;quot;&lt;br /&gt;
		citeq_args.asin = nil -- suppress ASIN if ISBN exists&lt;br /&gt;
	elseif citeq_args.journal then&lt;br /&gt;
		template = template or &amp;quot;journal&amp;quot;&lt;br /&gt;
	elseif citeq_args.website then&lt;br /&gt;
		template = template or &amp;quot;web&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- |id= could hold more than one identifier pulled from Wikidata not supported by {{citation}}, right now only add our qid to the list&lt;br /&gt;
	local list_sep = &amp;#039;. &amp;#039;&lt;br /&gt;
	if citeq_args.mode ~= &amp;#039;cs1&amp;#039; then&lt;br /&gt;
		list_sep = &amp;#039;, &amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	local id = cfg.i18n_t.wdq.. &amp;#039;&amp;amp;nbsp;[[:d:&amp;#039; .. qid .. &amp;#039;|&amp;#039; .. qid .. &amp;#039;]]&amp;#039; &lt;br /&gt;
	local old_id = citeq_args.id&lt;br /&gt;
	if wdl then -- show WD logo&lt;br /&gt;
		id = id .. &amp;#039;[[File:Wikidata-logo.svg|16px|alt=|link=]]&amp;#039; -- possibly replace by WD edit icon?&lt;br /&gt;
	end&lt;br /&gt;
	if is_set (old_id) then&lt;br /&gt;
		citeq_args.id = old_id .. list_sep .. id -- append to user-specified contents&lt;br /&gt;
	else&lt;br /&gt;
		citeq_args.id = id&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- clean up any blank parameters&lt;br /&gt;
	for k, v in pairs(citeq_args) do&lt;br /&gt;
		if v == &amp;quot;&amp;quot; then citeq_args[k] = nil end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- if |expand=&amp;lt;anything&amp;gt;, write a nowiki&amp;#039;d version to see what the {{citation}} template call looks like&lt;br /&gt;
	if expand then&lt;br /&gt;
		&lt;br /&gt;
		local expand_args = { &amp;quot;{{&amp;quot; .. (template and (&amp;quot;Cite &amp;quot;..template) or &amp;quot;Citation&amp;quot;) }	-- init with citation template&lt;br /&gt;
		if expand == &amp;quot;self&amp;quot; then&lt;br /&gt;
			citeq_args.id = old_id -- restore original |id= parameter&lt;br /&gt;
			expand_args = { cfg.i18n_t.cite_q .. qid } -- expand to itself&lt;br /&gt;
		end&lt;br /&gt;
		-- make a sortable table and sort it by param name&lt;br /&gt;
		local sorttable = {}&lt;br /&gt;
		for param, val in pairs (citeq_args) do&lt;br /&gt;
			table.insert(sorttable, {param, val})&lt;br /&gt;
		end&lt;br /&gt;
		table.sort(sorttable, comp_key)&lt;br /&gt;
		-- add contents to expand_args&lt;br /&gt;
		for idx, val in ipairs(sorttable) do&lt;br /&gt;
			table.insert(expand_args, val[1] .. &amp;#039;=&amp;#039; .. val[2])&lt;br /&gt;
		end&lt;br /&gt;
		-- make the nowiki&amp;#039;d string and done&lt;br /&gt;
		return frame:preprocess (table.concat ({&amp;#039;&amp;lt;syntaxhighlight lang=&amp;quot;wikitext&amp;quot; inline=&amp;quot;1&amp;quot;&amp;gt;&amp;#039;, table.concat (expand_args, &amp;#039; |&amp;#039;) .. &amp;#039;}}&amp;#039;, &amp;#039;&amp;lt;/syntaxhighlight&amp;gt;&amp;#039;}));&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local erratumid = getPropertyIDs( { &amp;quot;P2507&amp;quot;, qid = qid, fwd = &amp;quot;ALL&amp;quot;, osd = &amp;quot;no&amp;quot;, rank = &amp;quot;best&amp;quot;, maxvals = 1 } )&lt;br /&gt;
	if erratumid then&lt;br /&gt;
		erratumid = &amp;quot; [[d:&amp;quot; .. erratumid .. &amp;quot;|&amp;quot; .. cfg.i18n_t.erratum .. &amp;quot;]]&amp;quot; .. cfg.i18n_t.trackingcats.erratum&lt;br /&gt;
	else&lt;br /&gt;
		erratumid = &amp;quot;&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local opt_cat = &amp;#039;&amp;#039;&lt;br /&gt;
	if getValue( {&amp;quot;P5824&amp;quot;, ps = 1, qid = qid} ) then&lt;br /&gt;
		opt_cat = cfg.i18n_t.trackingcats.retracted&lt;br /&gt;
	end&lt;br /&gt;
	if getValue( {&amp;quot;P1366&amp;quot;, ps = 1, qid = qid} ) then&lt;br /&gt;
		opt_cat = opt_cat .. cfg.i18n_t.trackingcats.replaced&lt;br /&gt;
	end&lt;br /&gt;
	if not citeq_args.title then												-- emit category link if missing title&lt;br /&gt;
		opt_cat = opt_cat .. cfg.i18n_t.trackingcats[&amp;#039;no-label-or-title&amp;#039;];&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- render the template&lt;br /&gt;
	local lc_template = template and template:lower() or &amp;quot;citation&amp;quot;&lt;br /&gt;
	local output&lt;br /&gt;
	if cite_cfg.known_templates_t[lc_template] then&lt;br /&gt;
		local config_t = {[&amp;#039;CitationClass&amp;#039;] = cite_cfg.citation_classes_t[lc_template] or lc_template};	-- set CitationClass value&lt;br /&gt;
		output = require (cs1_module)._citation (nil, citeq_args, config_t)	-- go render the citation&lt;br /&gt;
	else&lt;br /&gt;
		output = frame:expandTemplate{											-- render the template&lt;br /&gt;
			title = &amp;quot;Cite &amp;quot;..template, args = citeq_args&lt;br /&gt;
		} .. cfg.i18n_t.trackingcats[&amp;quot;unknown-template&amp;quot;]&lt;br /&gt;
	end&lt;br /&gt;
	return output .. erratumid .. opt_cat&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function cite_q (frame)&lt;br /&gt;
	local args = {}&lt;br /&gt;
	for k, v in pairs(frame:getParent().args) do&lt;br /&gt;
		if v ~= &amp;quot;&amp;quot; then args[k] = v end&lt;br /&gt;
	end&lt;br /&gt;
	for k, v in pairs(frame.args) do&lt;br /&gt;
		if v ~= &amp;quot;&amp;quot; then args[k] = v end&lt;br /&gt;
	end&lt;br /&gt;
	args.qid = args.qid or args[1] or &amp;quot;&amp;quot;&lt;br /&gt;
	if args.qid == &amp;quot;&amp;quot; then return nil end&lt;br /&gt;
	args[1] = nil&lt;br /&gt;
&lt;br /&gt;
	local citesep = (args.citesep or &amp;quot;&amp;quot;)&lt;br /&gt;
	if citesep == &amp;quot;&amp;quot; then citesep = &amp;quot;, &amp;quot; end&lt;br /&gt;
	citesep = citesep:gsub(&amp;#039;&amp;quot;&amp;#039;, &amp;#039;&amp;#039;) -- strip double quotes after setting default to allow |citesep=&amp;quot;&amp;quot; as a blank separator&lt;br /&gt;
	args.citesep = nil&lt;br /&gt;
&lt;br /&gt;
	local tag = args.tag or &amp;quot;&amp;quot;&lt;br /&gt;
	if tag == &amp;quot;&amp;quot; then tag = nil end&lt;br /&gt;
	args.tag = nil&lt;br /&gt;
&lt;br /&gt;
	local list = args.list or &amp;quot;&amp;quot;&lt;br /&gt;
	if list == &amp;quot;&amp;quot; then list = nil end&lt;br /&gt;
	args.list = nil&lt;br /&gt;
&lt;br /&gt;
	args.language = args.language or args.lang&lt;br /&gt;
	args.lang = nil&lt;br /&gt;
&lt;br /&gt;
	local cites = {}&lt;br /&gt;
	for q in args.qid:gmatch(&amp;quot;Q%d+&amp;quot;) do&lt;br /&gt;
		-- make a new copy of the arguments&lt;br /&gt;
		local newargs = {}&lt;br /&gt;
		for k, v in pairs(args) do&lt;br /&gt;
			if k ~= &amp;quot;qid&amp;quot; then&lt;br /&gt;
				newargs[k] = v&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		newargs.qid = q&lt;br /&gt;
		if tag == &amp;quot;ref&amp;quot; then&lt;br /&gt;
			cites[#cites + 1] = frame:callParserFunction{ name = &amp;quot;#tag:ref&amp;quot;, args = { _cite_q(newargs), name = q } }&lt;br /&gt;
			-- expand like this: args = { _cite_q(newargs), name = &amp;#039;foo&amp;#039;, group = &amp;#039;bar&amp;#039; }&lt;br /&gt;
		else&lt;br /&gt;
			cites[#cites + 1] = _cite_q(newargs)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if list then&lt;br /&gt;
		return frame:expandTemplate{ title = list, args = cites }&lt;br /&gt;
	else&lt;br /&gt;
		return table.concat(cites, citesep)&lt;br /&gt;
	end&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;
	makeOrdinal = makeOrdinal,&lt;br /&gt;
	_getLangOfProp = _getLangOfProp,&lt;br /&gt;
	getLangOfProp = getLangOfProp,&lt;br /&gt;
	lang_code = lang_code,&lt;br /&gt;
	getPropOfProp = getPropOfProp,&lt;br /&gt;
	_cite_q = _cite_q,&lt;br /&gt;
	cite_q = cite_q&lt;br /&gt;
}&lt;/div&gt;</summary>
		<author><name>imported&gt;Trappist the monk</name></author>
	</entry>
</feed>