屿字五行属什么| 世袭罔替是什么意思| 什么是外阴白斑| 肚子绞痛吃什么药| 奇门遁甲什么意思| 额头容易出汗是什么原因| 白细胞多是什么意思| 送什么礼物| 焗是什么意思| 能量守恒是什么意思| 女性耻骨疼是什么原因| 加号是什么意思| 肾虚吃什么补最好| 螯合是什么意思| 为什么体检前不能喝水| 高血脂吃什么| 花椒和麻椒有什么区别| 射手男喜欢什么样的女生| 脂溢性脱发用什么药| 房客是什么意思| 1999年出生属什么生肖| 感冒应该挂什么科| 菩提子是什么材质| 什么奶粉跟母乳一个味| slay是什么意思| 韩语欧巴是什么意思| 小孩脸上长痣是什么原因引起的| 姜枣茶什么季节喝最好| 皮卡丘什么意思| 75年属什么的生肖| 六月下旬是什么时候| 绿树成荫是什么季节| les什么意思| 宁五行属什么| 冻梨是什么梨| 嘴紫是什么原因| 骨折吃什么恢复快| 看灰指甲去医院挂什么科| 胆结石不能吃什么东西| 心肌炎挂什么科| 手发抖是什么原因| 1950年属虎的是什么命| 子宫内膜不典型增生是什么意思| 为什么智齿到晚上更疼| 吃什么水果补钙| 绝经后子宫内膜增厚是什么原因| 广西属于什么气候| 靖国神社是什么地方| 88什么意思| 戴玉手镯有什么好处| 一动就大汗淋漓是什么原因| 粘土是什么土| 肚脐左上方是什么部位| 吃什么卵泡长得快又好| 儿童办理护照需要什么材料| 阴道润滑剂什么牌子好| 蚊子不喜欢什么味道| 嘴唇发白是什么原因引起的| 阴部毛变白是什么原因| 肝钙化灶什么意思| 息影是什么意思| 黄酒是什么酒| mfd是什么意思| fox什么意思| 水瓶座前面是什么星座| 宫腔积液和盆腔积液有什么区别| 土耳其说什么语言| 血红蛋白偏低吃什么补| 睡觉为什么流口水| 囊内可见卵黄囊是什么意思| 惊涛骇浪是什么意思| 2.7是什么星座| 为什么突然流鼻血| 什么叫方差| 耄耋是什么意思| 酸笋炒什么好吃| 眼睑炎用什么药| 城镇户口是什么意思| 什么奶粉跟母乳一个味| 减肥可以吃什么菜| 花荣的绰号是什么| 81年属什么的| 四川酸菜是什么菜| 善男信女什么意思| 吃山竹有什么好处| 交杯酒是什么意思| 吃什么能去湿气最好| 乙肝五项135阳性是什么意思| 飞机选座位什么位置好| 男女身份证号码有什么区分| 我想成为一个什么样的人| IOM是什么意思| 伏羲和女娲是什么关系| 京东自营店是什么意思| 为什么会便血| 左边太阳穴疼是什么原因| 甲状腺激素高吃什么药| yuki是什么意思| 后脑勺白头发多是什么原因| 丹参长什么样子图片| nu11是什么意思| 手淫有什么危害| 硬盘是什么| 复出是什么意思| 钟点房是什么意思| 徐峥的老婆叫什么名字| 吃什么补蛋白最快| 虢是什么意思| 拉肚子低烧是什么原因| 为什么会漏尿| 孕妇吃什么鱼| 太平鸟属于什么档次| 慢性咽炎挂什么科| 材料化学属于什么类| 野趣是什么意思| 你什么都可以| 什么叫前列腺钙化| 殿试是什么意思| 儿童头疼挂什么科| 全麻后为什么不能睡觉| 毛肚是什么| 柳州有什么大学| 兔子是什么意思| 生二胎应该注意什么| 精囊腺囊肿是什么意思| 什么是香港脚| 孕酮低有什么症状| 上呼吸道感染用什么药| 粑粑黑色是什么原因| 刮痧用的油是什么油| 肝硬化失代偿期是什么意思| 为什么拉屎是黑色的| 属虎是什么命| 看皮肤挂什么科| 地雷是什么意思| 日有所思夜有所梦是什么意思| gpt什么意思| 古驰是什么牌子| 启五行属什么| 妮子什么意思| 上火吃什么水果降火快| 门诊是什么意思| 牟利什么意思| 肾火吃什么药| 囊肿是什么引起的| 减肥晚餐适合吃什么| 天地人和是什么意思| 1994是什么年| 上上签什么意思| 人为什么会变| 1965年属什么| 香水前调中调后调是什么意思| 三手烟是什么意思| 减肥喝什么茶好| 三岁宝宝喝什么奶粉比较好| 特警是干什么的| 深度水解奶粉是什么意思| horns是什么意思| 秋天穿什么衣服| 飞行员妻子有什么待遇| 血常规是检查什么的| 糖宝是什么虫| 吃饭咬舌头是什么原因| 经期吃凉的东西有什么影响| 用什么挠脚心最痒| 宫保鸡丁宫保是指什么| 中筋面粉适合做什么| 世界上最大的鸟是什么鸟| 吸允的读音是什么| 为什么会长口腔溃疡的原因| 输卵管堵塞是什么原因造成的| 乐高是什么| 上火喝什么饮料| 冲床工是做什么的| 女人的逼长什么样| 梅开二度的意思是什么| 白内障有什么症状表现| 心脏大是什么原因| 炎症用什么药最好| 嘴角流口水是什么原因| 舌苔黄厚腻是什么原因| span是什么意思| 治疗幽门螺旋杆菌的四联药是什么| 摘胆对身体有什么影响| 半夜口渴是什么原因| 射手座和什么星座最配| 阴道里面痒是什么原因| 肺部感染吃什么药| 什么叫精神病| 心慌吃什么药好| 乳腺钼靶是什么意思| 为什么叫关东军| 抑郁是什么意思| 什么是执念| 流产能吃什么水果| 十岁女孩喜欢什么礼物| 南京是什么省| 书五行属性是什么| hb是什么意思医学| 市公安局政委是什么级别| 什么尾巴长不了| 什么会引起高血压| 完全性右束支传导阻滞是什么意思| 抗锯齿是什么意思| 滔滔不绝的绝什么意思| 菜园中有什么生肖| 双侧乳腺结构不良什么意思| 结肠炎吃什么药治疗效果好| 不着相是什么意思| 七月一日是什么节日| 胸口闷痛挂什么科| 谷氨酰转肽酶高什么原因| 阳痿是什么| 肝血不足吃什么中成药| 无锡有什么好玩的| 腰疼是什么病| 娃娃流鼻血是什么原因| 梦见大领导有什么预兆| 殚精竭虑是什么意思| camouflage什么意思| 牛仔布料是什么面料| 籽料是什么意思| 肾炎可以吃什么水果| 2月2日是什么星座| 维生素C起什么作用| 脉弦滑是什么意思| 喷昔洛韦乳膏治什么| 部堂大人是什么职位| 验尿细菌高是什么原因| 失眠吃什么好| 2月7日是什么星座| 手足口病是什么| 什么时候闰三月| 嘴麻是什么原因| 女人吃牛蛙有什么好处| 巴豆是什么| 月亮星座代表什么意思| 什么洗发水去屑好| 唐宝是什么意思| 安德玛是什么牌子| 眼镜什么品牌好| 社保缴费基数和工资有什么关系| 寿眉属于什么茶| 乳腺检查挂什么科| 尿素氮高什么原因| 投其所好是什么意思| 减肥有什么方法| 12月份是什么星座的| 甲功异常有什么症状| 梦见很多牛是什么兆头| 男人纹身纹什么运气好| 腋下有味道是什么原因| 眼袋大是什么原因| 青筋明显是什么原因| 什么的虫子| 今天什么地方地震了| 吃什么有助睡眠| 为什么明星都不戴黄金| 血压低吃什么东西好| 海子是什么意思| hpv感染吃什么药| 千斤拔泡酒有什么功效| 汗疱疹擦什么药| 隔离是什么意思| 百度Jump to content

凶猛的动物是什么生肖

Permanently protected module
From Wikipedia, the free encyclopedia

require('strict');
local getArgs = require ('Module:Arguments').getArgs;


--[[--------------------------< A R G S _ D E F A U L T >------------------------------------------------------

a table to specify initial values.

]]

local args_default = {
    group = '',
	bracket_left = '',
	bracket_right = '',
	bracket_year_left = '',
	bracket_year_right = '',
	postscript = '',
	page = '',
	pages = '',
	location = '',
	page_sep = ", p.&nbsp;",
	pages_sep = ", pp.&nbsp;",
	ref = '',
	template = 'harv',															-- if template name not provided in {{#invoke:}} use this
	};


--[[--------------------------< T A R G E T _ C H E C K >------------------------------------------------------

look for anchor_id (CITEREF name-list and year or text from |ref=) in anchor_id_list

the 'no target' error may be suppressed with |ignore-err=yes when target cannot be found because target is inside
a template that wraps another template; 'multiple targets' error may not be suppressed

]]

local function target_check (anchor_id, args)
	local namespace = mw.title.getCurrentTitle().namespace;
	local anchor_id_list_module = mw.loadData ('Module:Footnotes/anchor_id_list');
	local anchor_id_list = anchor_id_list_module.anchor_id_list;
	local article_whitelist = anchor_id_list_module.article_whitelist;
	local template_list = anchor_id_list_module.template_list;
    local citeref_patterns = anchor_id_list_module.citeref_patterns
	
	local whitelist_module = mw.loadData ('Module:Footnotes/whitelist');
	local whitelist = whitelist_module.whitelist;

	local tally = anchor_id_list[anchor_id];									-- nil when anchor_id not in list; else a tally
	local msg;
	local category;

	if not tally then
		if args.ignore then
			return '';															-- if ignore is true then no message, no category
		end
		
		if article_whitelist and article_whitelist[anchor_id] then				-- if an article-local whitelist and anchor ID is in it
			return '';															-- done
		end
		
		local wl_anchor_id = anchor_id;											-- copy to be modified to index into the whitelist
		
		if args.year then														-- for anchor IDs created by this template (not in |ref=) that have a date
			if args.year:match ('%d%l$') or										-- use the date value to determine if we should remove the disambiguator
				args.year:match ('n%.d%.%l$') or
				args.year:match ('nd%l$') then
					wl_anchor_id = wl_anchor_id:gsub ('%l$', '');				-- remove the disambiguator
			end
		end		

		local t_tbl = whitelist[wl_anchor_id];									-- get list of templates associated with this anchor ID

		if t_tbl then															-- when anchor ID not whitelisted t_tbl is nil
			for _, t in ipairs (t_tbl) do										-- spin through the list of templates associated with this anchor ID
				if template_list[t] then										-- if associated template is found in the list of templates in the article
					return '';													-- anchor ID is whitlisted and article has matching template so no error
				end
			end
		end

        for _, pattern in ipairs(citeref_patterns) do                           -- load patterns for wrapper templates on this page
           if anchor_id:match(pattern) then                                     -- spin through the special patterns and try to match
              return ''
           end
        end
  

		msg = 'no target: ' .. anchor_id;										-- anchor_id not found
mw.log(msg)
        if namespace == 10 and not args.show then                               -- do not generate error message in template namespace
           return ''
        end
		category = '[[Category:Harv and Sfn no-target errors]]';

	elseif 1 < tally then
		msg = 'multiple targets (' .. tally .. '×): ' .. anchor_id;				-- more than one anchor_id in this article
mw.log(msg)
        if namespace == 10 and not args.show then                               -- do not generate error message in template namespace
           return ''
        end
		category = 0 == namespace and '[[Category:Harv and Sfn multiple-target errors]]' or '';								-- only categorize in article space
		return '<span class="error harv-error" style="display: inline; font-size:100%"> ' .. args.template .. ' error: ' .. msg .. ' ([[:Category:Harv and Sfn template errors|help]])</span>' .. category;
	end

--	category = 0 == namespace and '[[Category:Harv and Sfn template errors]]' or '';	-- only categorize in article space
	category = 0 == namespace and category or '';								-- only categorize in article space

-- display based on args.show (no display by default)
    local display = args.show and 'inline' or 'none'
    return msg and '<span class="error harv-error" style="display: '..display..'; font-size:100%"> ' .. args.template .. ' error: ' .. msg .. ' ([[:Category:Harv and Sfn template errors|help]])</span>' .. category or '';

end


--[[--------------------------< I S _ Y E A R >----------------------------------------------------------------

evaluates param to see if it is one of these forms with or without lowercase letter disambiguator:
	YYYY
	n.d.
	nd	
	c. YYYY
	YYYY–YYYY	(separator is endash)
	YYYY–YY		(separator is endash)

return true when param has a recognized form; false else

]]

local patterns_date= {
	'^%d%d%d%d?%l?$',
	'^n%.d%.%l?$',
	'^nd%l?$',
	'^c%. %d%d%d%d?%l?$',
	'^%d%d%d%d–%d%d%d%d%l?$',
	'^%d%d%d%d–%d%d%l?$',
	}

local function is_year (param, args)
	args.year = '';																-- used for harv error; 
	
	for _, pattern in ipairs (patterns_date) do
		if mw.ustring.match (param, pattern) then
			args.year = param;													-- used for harv error; 
			return true;
		end
	end
end


--[[--------------------------< C O R E >----------------------------------------------------------------------

returns an anchor link (CITEREF) formed from one to four author names, year, and insource location (|p=, |pp=, loc=)

]]

local function core( args )
	local result;
	local err_msg = ''

	if args.P5 ~= '' then
		if is_year (args.P5, args) then
			result = table.concat ({args.P1, ' et al. ', args.bracket_year_left, args.P5, args.bracket_year_right});
		else
			args.P5 = '';														-- when P5 not a year don't include in anchor
			result = table.concat ({args.P1, ' et al.'});						-- and don't render it
		end

	elseif args.P4 ~= '' then
		if is_year (args.P4, args) then
			result = table.concat ({args.P1, ', ', args.P2, ' &amp; ', args.P3, ' ', args.bracket_year_left, args.P4, args.bracket_year_right});	-- three names and a year
		else
			result = table.concat ({args.P1, ' et al.'});						-- four names
		end

	elseif args.P3 ~= '' then
		if is_year (args.P3, args) then
			result = table.concat ({args.P1, ' &amp; ', args.P2, ' ', args.bracket_year_left, args.P3, args.bracket_year_right});	-- two names and a year
		else
			result = table.concat ({args.P1, ', ', args.P2, ' ', ' &amp; ', args.P3});	-- three names
		end
			
	elseif args.P2 ~= '' then
		if is_year (args.P2, args) then
			result = table.concat ({args.P1, ' ', args.bracket_year_left, args.P2, args.bracket_year_right});	-- one name and year
		else
			result = table.concat ({args.P1, ' &amp; ', args.P2});				-- two names
		end
		
	else
		result = args.P1;														-- one name
	end
																				-- when author-date result ends with a dot (typically when the last positional parameter holds 'n.d.')
																				-- and when no in-source location (no |p=, |pp=, or |loc=)
																				-- and when the first or only character in args.postscript is a dot
																				-- remove the author-date result trailing dot
																				-- the author-date result trailing dot will be replaced later with the content of args.postscript (usually a dot)
	if ('.' == result:sub(-1)) and ('.' == args.postscript:sub(1)) and ('' == args.page) and ('' == args.pages) and ('' == args.location) then
		result = result:gsub ('%.$', '');
	end
	
	if args.ref ~= 'none' then
		local anchor_id;
		if args.ref ~= '' then
			anchor_id = mw.uri.anchorEncode (args.ref);
			err_msg = target_check (anchor_id, args);
			result = table.concat ({'[[#', anchor_id, '|', result, ']]'});
		else
			anchor_id = mw.uri.anchorEncode (table.concat ({'CITEREF', args.P1, args.P2, args.P3, args.P4, args.P5}));
			err_msg = target_check (anchor_id, args);
			result = table.concat ({'[[#', anchor_id, '|', result, ']]'});
		end
	end

	if args.page ~= '' then
		result = table.concat ({result, args.page_sep, args.page});
	elseif args.pages ~= ''then
		result = table.concat ({result, args.pages_sep, args.pages});
	end      

	if args.location ~= '' then
		result = table.concat ({result, ', ', args.location});
	end

	result = table.concat ({args.bracket_left, result, args.bracket_right, args.postscript}):gsub ('%s+', ' ');		-- strip redundant spaces
	return result .. err_msg;
end


--[[--------------------------< H Y P H E N _ T O _ D A S H >--------------------------------------------------

Converts a hyphen to a dash under certain conditions.  The hyphen must separate
like items; unlike items are returned unmodified.  These forms are modified:
	letter - letter (A - B)
	digit - digit (4-5)
	digit separator digit - digit separator digit (4.1-4.5 or 4-1-4-5)
	letterdigit - letterdigit (A1-A5) (an optional separator between letter and
		digit is supported – a.1-a.5 or a-1-a-5)
	digitletter - digitletter (5a - 5d) (an optional separator between letter and
		digit is supported – 5.a-5.d or 5-a-5-d)

any other forms are returned unmodified.

str may be a comma- or semicolon-separated list

This code copied from Module:Citation/CS1.  The only modification is to require Module:Citation/CS1/Utilities
so that it has access to the functions is_set() and has_accept_as_written()

]]

local function hyphen_to_dash( str )
	local utilities = require ('Module:Citation/CS1/Utilities');				-- only modification so that this function has access to is_set() and has_accept_as_written()

	if not utilities.is_set (str) then
		return str;
	end

	local accept; -- Boolean

	str = str:gsub ('&[nm]dash;', {['&ndash;'] = '–', ['&mdash;'] = '—'});		-- replace &mdash; and &ndash; entities with their characters; semicolon mucks up the text.split
	str = str:gsub ('&#45;', '-'); -- replace HTML numeric entity with hyphen character

	str = str:gsub ('&nbsp;', ' '); -- replace &nbsp; entity with generic keyboard space character
	
	local out = {};
	local list = mw.text.split (str, '%s*[,;]%s*');								-- split str at comma or semicolon separators if there are any

	for _, item in ipairs (list) do												-- for each item in the list
		item, accept = utilities.has_accept_as_written (item);					-- remove accept-this-as-written markup when it wraps all of item
		if not accept and mw.ustring.match (item, '^%w*[%.%-]?%w+%s*[%-–—]%s*%w*[%.%-]?%w+$') then	-- if a hyphenated range or has endash or emdash separators
			if item:match ('^%a+[%.%-]?%d+%s*%-%s*%a+[%.%-]?%d+$') or			-- letterdigit hyphen letterdigit (optional separator between letter and digit)
				item:match ('^%d+[%.%-]?%a+%s*%-%s*%d+[%.%-]?%a+$') or			-- digitletter hyphen digitletter (optional separator between digit and letter)
				item:match ('^%d+[%.%-]%d+%s*%-%s*%d+[%.%-]%d+$') or			-- digit separator digit hyphen digit separator digit
				item:match ('^%d+%s*%-%s*%d+$') or								-- digit hyphen digit
				item:match ('^%a+%s*%-%s*%a+$') then							-- letter hyphen letter
					item = item:gsub ('(%w*[%.%-]?%w+)%s*%-%s*(%w*[%.%-]?%w+)', '%1–%2');	-- replace hyphen, remove extraneous space characters
			else
				item = mw.ustring.gsub (item, '%s*[–—]%s*', '–');				-- for endash or emdash separated ranges, replace em with en, remove extraneous whitespace
			end
		end
		table.insert (out, item);												-- add the (possibly modified) item to the output table
	end

	local temp_str = '';														-- concatenate the output table into a comma separated string
	temp_str, accept = utilities.has_accept_as_written (table.concat (out, ', ')); -- remove accept-this-as-written markup when it wraps all of concatenated out
	if accept then
		temp_str = utilities.has_accept_as_written (str);						-- when global markup removed, return original str; do it this way to suppress boolean second return value
		return temp_str;
	else
		return temp_str;														-- else, return assembled temp_str
	end
end


--[[--------------------------< A R G S  _ F E T C H >---------------------------------------------------------

Because all of the templates share a common set of parameters, a single common function to fetch those parameters
from frame and parent frame.

]]

local function args_fetch (frame, ps)
	local args = args_default;													-- create a copy of the default table
	local pframe = frame:getParent();											-- point to the template's parameter table

	for k, v in pairs (frame.args) do											-- override defaults with values provided in the #invoke: if any
		args[k] = v;	   
	end
	
	args.postscript = pframe.args.postscript or pframe.args.ps or ps;
	if 'none' == args.postscript then
		args.postscript = '';
	end
	args.group = pframe.args.group or '';
	args.page = pframe.args.p or pframe.args.page or '';
	args.pages = pframe.args.pp or pframe.args.pages or '';
	args.pages = ('' ~= args.pages) and hyphen_to_dash (args.pages) or '';
	args.location = pframe.args.at or pframe.args.loc or '';
	args.ref = pframe.args.ref or pframe.args.Ref or '';
	args.ignore = ('yes' == pframe.args['ignore-false-positive']) or ('yes' == pframe.args['ignore-err']);

	for i, v in ipairs ({'P1', 'P2', 'P3', 'P4', 'P5'}) do						-- loop through the five positional parameters and trim if set else empty string
		args[v] = (pframe.args[i] and mw.text.trim (pframe.args[i])) or '';
	end

	if args.P5 and not is_year (args.P5, args) then
		local i = 6;															-- initialize the indexer to the sixth positional parameter
		while pframe.args[i] do													-- in case there are too many authors loop through the authors looking for a year
			local v = mw.text.trim (pframe.args[i]);							-- trim
			if is_year (v, args) then											-- if a year
				args.P5 = v;													-- overwrite whatever was in args.P5 with year
				break;															-- and abandon the search
			end
			i = i + 1;															-- bump the indexer
		end
	end
	return args;
end


--[[--------------------------< H A R V A R D _ C I T A T I O N >----------------------------------------------

common entry point for:
	{{harvard citation}} aka {{harv}}
	{{Harvard citation no brackets}} aka {{harvnb}}
	{{harvcol}}
	{{harvcolnb}}
	{{harvcoltxt}}
	{{Harvard citation text}} aka {{harvtxt}}
	{{Harvp}}

Distinguishing features (brackets and page separators) are specified in this module's {{#invoke}} in the respective templates.

]]

local function harvard_citation (frame)
	local args = args_fetch (frame, '');										-- get the template and invoke parameters; default postscript is empty string

	return core (args);
end


--[[--------------------------< S T R I P _ U R L >------------------------------------------------------------

used by sfn() and sfnm().  This function fixes an issue with reference tooltip gadget where the tooltip is not displayed
when an insource locator (|p=, |pp=, |loc=) has an external wikilink that contains a # character

strip uri-reserved characters from urls in |p=, |pp-, and |loc= parameters  The researved characters are:
	!#$&'()*+,/:;=?@[]
	
]]

local function strip_url (pages)
	local escaped_uri;
	if not pages or ('' == pages) then
		return pages;
	end
	
	for uri in pages:gmatch ('%[(%a[%w%+%.%-]*://%S+)') do						-- for each external link get the uri
		escaped_uri = uri:gsub ("([%(%)%.%%%+%-%*%?%[%^%$%]])", "%%%1" );		-- save a copy with lua pattern characters escaped
		uri = uri:gsub ("[!#%$&'%(%)%*%+,/:;=%?@%[%]%.%%]", '');				-- remove reserved characters and '%' because '%20' (space character) is a lua 'invalid capture index'
		pages = pages:gsub (escaped_uri, uri, 1);								-- replace original uri with the stripped version
	end
	
	return pages;
end


--[[--------------------------< S F N >------------------------------------------------------------------------

entry point for {{sfn}} and {{sfnp}}

]]

local function sfn (frame)
	local args = args_fetch (frame, '.');										-- get the template and invoke parameters; default postscript is a dot

	local result = core (args);													-- go make a CITEREF anchor
																				-- put it all together and then strip redundant spaces
	local name = table.concat ({'FOOTNOTE', args.P1, args.P2, args.P3, args.P4, args.P5, strip_url (args.page), strip_url (args.pages), strip_url (args.location)}):gsub ('%s+', ' ');

	return frame:extensionTag ({name='ref', args={group=args.group, name=name}, content=result});	

	
end


--[[--------------------------< S F N M >----------------------------------------------------------------------

common entry point for {{sfnm}} and {{sfnmp}}

Distinguishing features (brackets) are specified in this module's {{#invoke}} in the respective templates.

]]

local function sfnm (frame)
	local args = args_default;													-- create a copy of the default table
	local pframe = frame:getParent();											-- point to the template's parameter table
	
	local n = 1;																-- index of source; this is the 'n' in na1, ny, etc
	local first_pnum = 1;														-- first of a pair of positional parameters
	local second_pnum = 2;														-- second of a pair of positional parameters

	local last_ps = 0;															-- index of the last source with |nps= set
	local last_index = 0;														-- index of the last source; these used to determine which of |ps= or |nps= will terminate the whole rendering

	local out = {};																-- table to hold rendered sources
	local footnote = {'FOOTNOTE'};												-- all author, date, insource location stuff becomes part of the reference's footnote id; added as we go

	for k, v in pairs (frame.args) do											-- override defaults with values provided in the #invoke: if any
		args[k] = v;	   
	end
	
	while true do
		if not pframe.args[table.concat ({n, 'a1'})] and not pframe.args[first_pnum] then
			break;																-- no na1 or matching positional parameter so done
		end
		
		if pframe.args[table.concat ({n, 'a1'})] then							-- does this source use named parameters?
			for _, v in ipairs ({'P1', 'P2', 'P3', 'P4', 'P5'}) do				-- initialize for this source
				args[v] = '';
			end

			for i, v in ipairs ({'P1', 'P2', 'P3', 'P4', 'P5'}) do				-- extract author and year parameters for this source
				args[v] = pframe.args[table.concat ({n, 'a', i})] or '';		-- attempt to assign author name
				if '' == args[v] then											-- when there wasn't an author name
					args[v] = pframe.args[table.concat ({n, 'y'})] or '';		-- attempt to assign year
					break;														-- done with author/date for this source
				end
			end

		else																	-- this source uses positional parameters
			args.P1 = mw.text.trim (pframe.args[first_pnum]);					-- yes, only one author supported
			args.P2 = (pframe.args[second_pnum] and mw.text.trim (pframe.args[second_pnum])) or '';	-- when positional author, year must also be positional

			for _, v in ipairs ({'P3', 'P4', 'P5'}) do							-- blank the rest of these for this source
				args[v] = '';
			end

			first_pnum = first_pnum + 2;										-- source must use positional author and positional year
			second_pnum = first_pnum + 1;										-- bump these for possible next positional source
		end
		
		args.postscript = pframe.args[table.concat ({n, 'ps'})] or '';
		if 'none' == args.postscript then										-- this for compatibility with other footnote templates; does nothing
			args.postscript = '';
		end
		args.group = pframe.args.group or '';									-- reference group
		args.ref = pframe.args[table.concat ({n, 'ref'})] or '';				-- alternate reference for this source

		args.page = pframe.args[table.concat ({n, 'p'})] or '';					-- insource locations for this source
		args.pages = pframe.args[table.concat ({n, 'pp'})] or '';
		args.pages = ('' ~= args.pages) and hyphen_to_dash (args.pages) or '';
		args.location = pframe.args[table.concat ({n, 'loc'})] or pframe.args[table.concat ({n, 'at'})] or '';
		args.ignore = ('yes' == pframe.args[table.concat ({n, 'ignore-false-positive'})]) or ('yes' == pframe.args[table.concat ({n, 'ignore-err'})]);

		table.insert (out, core (args));										-- save the rendering of this source
		
		for k, v in ipairs ({'P1', 'P2', 'P3', 'P4', 'P5'}) do					-- create the FOOTNOTE id
			if '' ~= args[v] then
				table.insert (footnote, args[v]);
			end
		end
		for k, v in ipairs ({'page', 'pages', 'location'}) do					-- these done separately so that we can strip uri-reserved characters from extlinked page numbers 
			if '' ~= args[v] then
				table.insert (footnote, strip_url (args[v]))
			end
		end
		
		last_index = n;															-- flags used to select terminal postscript from nps or from end_ps
		if '' ~= args.postscript then							
			last_ps = n;
		end
		
		n = n+1;																-- bump for the next one
	end
	
	local name = table.concat (footnote):gsub ('%s+', ' ');						-- put the footnote together and strip redundant space
	
	args.end_ps = pframe.args.postscript or pframe.args.ps or '.';				-- this is the postscript for the whole not for the individual sources
	if 'none' == args.end_ps then												-- not an original sfnm parameter value; added for compatibility with other footnote templates
		args.end_ps = '';
	end

	local result = table.concat ({table.concat (out, '; '), (last_index == last_ps) and '' or  args.end_ps});
	return frame:extensionTag ({name='ref', args={group=args.group, name=name}, content=result});
end


--[[--------------------------< S F N R E F >------------------------------------------------------------------

implements {{sfnref}}

]]

local function sfnref (frame)
	local args = getArgs (frame);
	local out = {};
	
	for i=1, 5 do																-- get the first five args if there are five args
		if args[i] then
			out[i] = args[i];
		else
			break;																-- less than 5 args break out
		end
	end
	
	if 5 == #out then															-- when we have seen five args there may bemore
		local i = 6;															-- initialize the indexer to the sixth positional parameter
		while args[i] do														-- in case there are too many authors loop through the authors looking for a year
			if is_year (args[i], args) then										-- if a year
				out[5] = args[i];												-- overwrite whatever was in args[5] with year
				break;															-- and abandon the search
			end
			i = i + 1;															-- bump the indexer
		end
	end
	
	return mw.uri.anchorEncode ('CITEREF' .. table.concat (out));
end


--[[--------------------------< E X P O R T E D   F U N C T I O N S >------------------------------------------
]]

return {
	harvard_citation = harvard_citation,
	sfn = sfn,
	sfnm = sfnm,
	sfnref = sfnref,
    target_check = target_check,
	};
清影是什么意思 湿气重是什么原因造成的 什么啤酒好喝 普洱茶属于什么茶类 安痛定又叫什么
高筋面粉和低筋面粉有什么区别 过氧化氢浓度阳性是什么意思 病毒感染咳嗽吃什么药效果好 双肺结节是什么意思 为什么要备孕
爷爷的妈妈叫什么 下面潮湿是什么原因引起的 什么是湿气重 沉鱼落雁闭月羞花什么意思 俊五行属什么
褒义词什么意思 月经期间头疼是什么原因 牙疼吃什么水果好 洋姜学名叫什么 韩束属于什么档次
三花聚顶是什么修为hcv9jop6ns4r.cn 西瓜和什么相克hcv8jop5ns0r.cn 平方是什么意思hcv8jop7ns8r.cn 梦见自己生个女孩是什么意思hcv8jop4ns0r.cn 银925是什么意思hcv9jop0ns1r.cn
看情况是什么意思hcv9jop5ns0r.cn 秋黄瓜什么时候种hcv8jop7ns6r.cn 蓁字五行属什么hcv7jop6ns9r.cn 额头长痘是因为什么hcv8jop4ns8r.cn 血压低压高是什么原因hcv9jop4ns1r.cn
床上有横梁有什么害处hcv7jop5ns6r.cn 红薯是什么茎hcv8jop5ns4r.cn 吽是什么意思hcv9jop0ns9r.cn 备孕吃什么最容易怀孕hcv7jop6ns5r.cn 什么牙膏好用dajiketang.com
裂帛是什么意思hcv9jop5ns9r.cn 谣言是什么意思huizhijixie.com 小孩智力发育迟缓挂什么科hcv8jop1ns2r.cn 3月10号什么星座hcv9jop4ns6r.cn 少将是什么级别hcv9jop2ns6r.cn
百度