嘴巴里长血泡是什么原因| 热退疹出是什么病| 综合内科是看什么病| 气血不足看什么科室| 人为什么打嗝| 以讹传讹什么意思| 卵巢早衰有什么症状| 知了为什么会叫| 梦见好多南瓜是什么意思| 手抖是因为什么| 吃什么东西对肾好| 心得安是什么药| 什么原因造成糖尿病| 喉咙痛吃什么水果好得最快| mmf是什么药| 女生什么时候是安全期| 无味是什么意思| 2002年属什么生肖| 长期上夜班对身体有什么危害| 忏悔是什么意思| 什么是妈妈臀| 婴儿哭久了有什么危害| 低回声结节是什么意思| 水肿吃什么药消肿最快最有效| 快乐源泉是什么意思| 外阴溃烂用什么药| 胎动频繁到什么程度说明缺氧| cook什么意思| 人和是什么意思| 为什么被蚊子咬了会起包| 经常吃红枣有什么好处和坏处| 阴囊潮湿什么原因| 吃什么药可以延长射精| 雨落心尘是什么意思| 欲生欲死是什么意思| 白色念珠菌是什么意思| 大姨妈是什么| mint什么颜色| 特别怕热爱出汗是什么原因| 为什么总是想吐| 2005年属鸡是什么命| 始于初见止于终老是什么意思| 黄色配什么颜色| 捉奸什么意思| 血压高吃什么好| 妄想症有什么症状| 83属什么生肖| 腮腺炎反复发作是什么原因| 凝血四项是检查什么的| 中国最大的海是什么海| 奥美拉唑是什么药| 膝关节疼痛吃什么药好| 优雅知性是什么意思| mechrevo是什么牌子的电脑| 灵芝对身体有什么好处| ccu是什么| 黑素瘤早期什么症状| 较前相仿是什么意思| 常委是什么级别| 皮肤爱出油是什么原因| shit什么意思中文| 泌尿外科看什么病| 父亲节什么时候| 前白蛋白低是什么意思| 衣原体感染有什么症状| 08是什么生肖| 梨状肌综合症吃什么药| 2023年属兔的是什么命| 巡礼是什么意思| 一个虫一个夫念什么| 来月经前有褐色分泌物是什么原因| 断掌什么意思| 梦见给别人钱是什么意思| 7月25号是什么星座| 献血前吃什么东西最好| 申时出生五行缺什么| lofter是什么意思| 月子能吃什么水果| 汗马功劳什么意思| 外阴白斑有什么症状| 姜虫咬人有什么症状| 血氨高是什么原因| 鳀鱼是什么鱼| 为什么放生泥鳅果报大| 什么叫打板| 水瓶座什么性格| 高碱性食物都有什么| 上厕所出血是什么原因| 气短心悸是什么意思| 什么时间量血压最准| 脚出汗是什么原因| 生化全项包括什么| 理气是什么意思| 转氨酶高是什么病| 严重失眠吃什么中成药| 正装是什么样的衣服| 细菌性阴道炎用什么药好| 童子是什么意思| 1.17是什么星座| 血热吃什么药快速见效| 什么是坏血病| 天伦之乐什么意思| 蚊子代表什么生肖| 肛门痒痒的是什么原因| 做梦梦见老婆出轨是什么意思| 多囊卵巢是什么意思| qcy是什么牌子| 什么的糖果| 长期失眠吃什么药| 翼龙吃什么| 脸霜什么牌子的好| ipf是什么病| 头晕是什么情况| 什么东西可以减肥| 牛肉和什么炒| 颈椎曲度变直是什么意思| 景色奇异的异是什么意思| 腿软无力是什么原因| or发什么音| 蚊子为什么会咬人| 山峦是什么意思| 新疆有什么湖| 喝中药能吃什么水果| 月亮象征着什么| 香波是什么| 小腹胀是什么原因女性| 泌尿系统感染挂什么科| 夏季适合种什么花| 禹五行属什么| 一什么景象| 吃什么补钾| wrong什么意思| 头皮痒掉发严重是什么原因| 喉咙痛喝什么| 多少年婚姻是什么婚| 堪忧是什么意思| 心悸吃什么药效果好| 爵是什么器皿| 突然戒烟对身体有什么影响| 耳道炎是什么原因引起的| 家庭出身填什么| 指甲花学名叫什么| 东莞有什么好玩的| 子宫内膜3mm意味着什么| 无事不登三宝殿什么意思| 胸推是什么意思| 扁桃体切除对身体有什么影响| 新股配号数量是什么意思| 毛发变白是什么原因| 射手男和什么座最配对| 命门是什么意思| 鸭肫是什么部位| 阴历六月十八是什么日子| 圆珠笔是什么笔| 吃什么能提高性功能| av是什么| 翻糖蛋糕是什么意思| 壮阳是什么意思| 哀嚎是什么意思| 黑手是什么意思| 宫颈锥切后需要注意什么| 糖尿病人早餐吃什么最好| 为什么有狐臭| 腺癌是什么原因引起的| 阿迪达斯和三叶草有什么区别| 腿弯处的筋痛是什么原因| 梦见蛇预示着什么| 灵芝孢子粉有什么作用| 后脖子出汗多是什么原因| 有机会是什么意思| 什么情况下需要做活检| 更年期有什么症状| 尿毒症前兆是什么症状表现| 白敬亭原名叫什么| 小孩c反应蛋白高说明什么| 大姨妈喝什么汤好| 手臂痛什么原因| 银梳子梳头有什么好处和坏处| 尿素氮偏低是什么意思| 土字旁的字有什么| b型血为什么招蚊子| 二氧化碳结合力是什么| choice是什么意思| 梦见偷别人东西是什么意思| 尬是什么意思| 梦见做被子什么意思| 婧五行属什么| 28什么意思| 肛门疼痛什么原因| 倒斗是什么意思| 横纹肌溶解什么意思| 长方形纸可以折什么| 3.21什么星座| 腱鞘炎用什么药能治好| 熹字五行属什么| 吃什么东西对肾好| 阴中求阳是什么意思| 现在执行死刑用什么方法| 甲状腺在人体什么位置| 小狗吃什么| 什么是聚酯纤维面料| 肴肉是什么肉| 小孩脚麻是什么原因| 咳嗽喝什么饮料| 家里养泥鳅喂什么东西| 手脱皮是缺什么| 胡子长的快是什么原因| 四月十六是什么星座| 什么得什么的| 泰国的钱叫什么| 海口有什么好玩的| cbs是什么意思| 一五行属性是什么| 艾灸有什么好处| 记性不好吃什么药| 床上放什么可以驱虫| 肠胃不好吃什么| 什么情况需要割包皮| 走后门什么意思| 吃什么菜能降血糖| 温碧泉属于什么档次| 月经2个月没来是什么原因| 糖尿病人吃什么水果好| 梦见香蕉是什么意思| 鱼扣是鱼的什么部位| 末法时期是什么意思| 分割线是什么意思| 能是什么意思| 垂头丧气什么意思| 玻璃体混浊用什么眼药水| 情趣什么意思| 咸鸭蛋不能和什么一起吃| 薄荷脑是什么| 什么叫网红| 修缮是什么意思| 临床医学学什么| 吃藕是什么意思| 大姨妈来了可以吃什么水果| 脚背有痣代表什么| 什么3121919Z空间| 买手机上什么网| 香港特首是什么级别| 幽冥是什么意思| 神经元特异性烯醇化酶是什么意思| 丈夫的弟弟叫什么| 堪堪是什么意思| 什么可以美白牙齿| 默然是什么意思| 尼龙是什么| 上火流鼻血是什么原因| 26度穿什么衣服| 维生素h是什么| 梦见被追杀是什么预兆| 什么的落日| 经常的近义词是什么| 决明子是什么东西| 不等是什么意思| 杨新鸣包贝尔什么关系| b超能检查出什么| 痛风吃什么好| 寻麻疹看什么科| 王京读什么| 息肉样增生是什么意思| 为什么空调外机会滴水| 百度Hopp til innhald

衣食住行一键解决 消费体验不断刷新 全民消费开启在线生活

Fr? Wikipedia – det frie oppslagsverket
百度 希澈就笑指:所有人都没想过两人是谈恋爱。

Dokumentasjon for modulen kan opprettast p? Modul:Fotnotar/dok


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 = {
	bracket_left = '',
	bracket_right = '',
	bracket_year_left = '',
	bracket_year_right = '',
	postscript = '',
	page = '',
	pages = '',
	location = '',
	page_sep = ", s.&nbsp;",
	pages_sep = ", s.&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.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={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.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={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,
	};
呕吐挂什么科 肺不好挂什么科 血糖高的人早餐吃什么好 什么地什么 床虱咬了要擦什么药膏
狸猫是什么动物 慕名而来是什么意思 年轻人手抖是什么原因 脑软化灶是什么意思 esim卡是什么
彩宝是什么 什么除湿气效果最好 骨皮质是什么 dsa检查是什么 1977年是什么年
小便尿色黄是什么问题 一花一世界一叶一菩提什么意思 什么花喜欢磷酸二氢钾 毫无违和感是什么意思 食用植物油是什么油
邦字五行属什么hcv7jop4ns6r.cn 为什么不来大姨妈也没有怀孕hcv7jop9ns9r.cn 附件炎用什么药最好hcv8jop5ns9r.cn 什么机油好hcv9jop6ns7r.cn 眼睛红是什么原因luyiluode.com
上火耳鸣吃什么药最好hcv8jop8ns7r.cn 每天早上起床头晕是什么原因hcv9jop6ns3r.cn 牛头不对马嘴是什么意思aiwuzhiyu.com 广义货币m2是什么意思hcv8jop8ns9r.cn 低钾血症吃什么食补hcv8jop7ns6r.cn
参芪颗粒适合什么人吃hcv8jop1ns0r.cn 梦见莲藕是什么意思hcv9jop6ns0r.cn 摩羯座和什么座最配对hcv7jop9ns2r.cn 过氧化氢阳性什么意思hcv8jop5ns0r.cn 赫五行属性是什么hcv8jop3ns0r.cn
西安有什么美食hcv7jop6ns4r.cn 门面是什么意思hcv9jop1ns3r.cn 脸部痒是什么原因hcv9jop5ns3r.cn 肝脏排毒吃什么最好hcv8jop1ns4r.cn 慢性肠炎吃什么药效果好luyiluode.com
百度