缺钾有什么症状| 肾不好会出现什么症状| 腋窝淋巴结肿大挂什么科| 6月6日什么星座| 什么是富贵包| 小猫吃什么东西| 排卵试纸阴性是什么意思| robam是什么牌子| 脉搏高是什么原因| 生水是什么意思| 总动员是什么意思| 荨麻疹是什么| 外甥女是什么关系| 药流前需要做什么检查| 长期肚子疼是什么原因| 不能吃辣是什么原因| 酸豆角炒什么好吃| 区委副书记是什么级别| 孩子不愿意吃饭是什么原因| 闪失是什么意思| 仕途是什么意思| 外科主要看什么病| 什么生肖没有牙齿| 为什么低血压| 感冒有痰吃什么药| 哦哦是什么意思| mic是什么| 梦见杀鸡是什么预兆| 手术前吃什么补充营养| 干什么呢| 尿多是什么原因女性| 甲状腺不能吃什么食物| 驿什么意思| 东是什么生肖| jdk是什么| 脂蛋白a高吃什么能降下来| 身份证号最后一位代表什么| 肝多发钙化灶什么意思| 左眼跳什么| 蓝色和红色混合是什么颜色| 小巧玲珑是什么意思| 骶管小囊肿是什么意思| 吃什么容易瘦| 八月十五是什么日子| 什么病可以申请低保| 白衬衫太透里面穿什么| 左胸下面是什么部位| 封闭针是什么| 香港车牌号是什么样子| 补体c4偏低是什么意思| 心内科全称叫什么| 鸽子配什么煲汤最好| 乙肝阴性是什么意思| 三七粉主要治什么病| 青鱼又叫什么鱼| 尿频是什么原因引起的| 甲亢是什么| 左肋骨下方是什么器官| 笔芯是什么意思| 鸡肉和什么相克| 睡觉容易惊醒是什么原因| 虚荣心是什么意思| 爱上一个人是什么感觉| 查甲功是什么意思| 50岁今年属什么生肖| 游离前列腺特异性抗原是什么意思| 洋葱吃多了有什么坏处| 辛字五行属什么| 甘油三酯高说明什么| 4月17是什么星座| 荷花什么时候开| design是什么牌子| 女性前列腺叫什么| 逻辑性是什么意思| 准生证是什么样子图片| 今年是什么年庚| 大姨妈血块多是什么原因| 房颤挂什么科| 什么叫市级以上医院| 女生没有腋毛代表什么| m是什么| 泛醇是什么| 晚上睡觉遗精是什么原因| 大乔叫什么| 及什么意思| 头顶头发稀少是什么原因| 姜子牙是什么神仙| 闭麦是什么意思| 肌无力是什么病| 一代表什么意思| 健脾祛湿吃什么药| 肋骨骨折挂什么科| 锌中毒是什么症状| 金牛座有什么特点| 伪娘是什么意思| pin什么意思| 8月15号是什么星座| 手关节黑是什么原因| 怀孕什么时候显怀| columbia是什么牌子| geya是什么牌子的手表| bigbang什么意思| 脑梗吃什么药可以恢复的快| 心率快吃什么中成药| 麦粒肿是什么原因引起的| 16岁可以做什么工作| 益生菌对人体有什么好处| 未属什么五行| 钟爱一生是什么意思| 张国荣什么时候去世的| 子宫前倾是什么意思| 梦见虫子是什么意思| 黑灰色是什么颜色| 头晕到医院看什么科| 什么发型好看| 心肌酶高有什么症状| 检查胃挂什么科| 送奶奶什么礼物好| 肌红蛋白低说明什么| 氨水是什么| 女生第一次什么感觉| 恩客是什么意思| 孩子不愿意吃饭是什么原因| 考试前不能吃什么| 做什么生意挣钱| aug什么意思| 抽血抽不出来是什么原因| 婴儿足底血筛查什么| 不自觉是什么意思| 白兰地是什么酒| 脑部磁共振检查什么| 喝酒头疼是什么原因| 软柿子是什么意思| 小浣熊吃什么| 收割是什么意思| 芭蕉和香蕉有什么区别| 预防脑梗吃什么药| 浙江有什么城市| 左侧附件区囊性回声是什么意思| 为什么一动就满头大汗| 风湿三项检查是什么| 轱辘是什么意思| 哗众取宠是什么意思| 春回大地是指什么生肖| 人体消化道中最长的器官是什么| 甲状腺回声不均匀什么意思| 12.6是什么星座| 脚麻木吃什么药| 什么病不能吃海参| 孕妇胃疼可以吃什么药| 尿道炎用什么药治疗最好| c14呼气试验是检查什么的| 夏天适合穿什么衣服| 鳖吃什么| 眼压高是什么意思| ppa是什么药| 地黄泡水喝有什么好处| 花序是什么意思| 无眠是什么意思| 月经推迟什么原因| 心房颤动是什么意思| 眼皮肿什么原因引起的| 胃发热是什么原因| 姜黄粉是什么| 鸡的贵人是什么生肖| 憨厚老实是什么意思| captain是什么意思| 梦见死人和棺材预示着什么| 什么情况下才做冠脉cta| 尿泡沫多吃什么药| 过敏性咳嗽用什么药| 1995年属什么生肖| 番茄和西红柿有什么区别| 指南针什么时候发明的| 刮痧不出痧是什么原因| ap医学上是什么意思| 什么是刷酸| 手足口病用什么药| 六合是什么意思| 拉肚子吃什么抗生素| 什么是射精| 激素6项什么时候查| 四个人念什么| 为什么脚臭叫香港脚| 胆囊息肉有什么症状| 早射吃什么药可以调理| 慢慢张开你的眼睛是什么歌的歌词| 做一半就软了是什么原因| 念珠菌用什么药| 扁桃体切除对身体有什么影响| stella是什么意思| 死刑是什么意思| 大头鱼吃什么食物| 7月22日是什么星座| 关门弟子是什么意思| 月经不正常去医院检查什么项目| 不打狂犬疫苗会有什么后果| MS医学上是什么意思| 毛发旺盛女生什么原因引起的| 肌酐是什么意思| 住院医师是什么意思| 修造是什么意思| 几天不大便是什么原因| 什么是感统失调| 公务员干什么工作| 落汤鸡是什么意思| 全职什么意思| 印度古代叫什么| 什么是大小周| 急支糖浆是什么梗| 肾病综合症是什么病| 菜心是什么菜| 抗病毒什么药效果好| 晚上睡觉遗精是什么原因| 什么叫化学性肝损伤| 六月中旬是什么时候| 什么是杀猪菜| 大肠杆菌是什么意思| 游龙戏凤是什么意思| 指控是什么意思| 早上起床想吐是什么原因| 苦海无涯回头是岸是什么意思| 怀孕初期吃什么好| 水压低用什么花洒| 色觉异常是什么意思| 细菌性结膜炎用什么药| 低血糖什么不能吃| 囊肿什么意思| 高铁上不能带什么东西| 崎岖是什么意思| 馒头配什么菜好吃| 妇炎康片有什么副作用| 为什么特别招蚊子| 什么像什么又像什么| 舌苔厚白湿气重吃什么药| 香茗是什么意思| 逆水行舟什么意思| 反流性食管炎可以吃什么水果| 维生素b2有什么功效| 剑玉是什么| 儿童坐飞机需要带什么证件| 梦见初恋男友是什么意思| 浙江大学什么专业最好| 秋刀鱼是什么鱼| 手心发红是什么原因| 为什么手会发麻| 3月29日是什么星座| 放疗有什么危害| 去澳门需要什么证件| 气短咳嗽是什么原因引起的| 什么病会引起腰疼| 一什么话| 什么是梦| 毛主席什么时候去世| 早餐吃什么不会胖| 角色扮演是什么意思| 女右眉毛跳是什么预兆| 79年出生属什么生肖| 豆汁是什么| henry是什么意思| 牙齿黄是什么原因造成的| 生不如死是什么生肖| 心存善念是什么意思| 四月八日是什么星座| 百度

【今日我当班】感受检察官的公平正义

Documentation icon Dokumentacija modula[predogled] [uredi] [zgodovina] [osve?i]
百度 夏目贵志手办模型背着娘口三三,还拿着书本的夏目,一下子就让人想到了翻剧里面二者之间简单却又不平淡的生活。

Implements {{sfn}}, {{harvard citation}}, and variants of those templates.

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 = ", str.&nbsp;",
	pages_sep = ", str.&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 whitelist_module = mw.loadData ('Module:Footnotes/whitelist');
	local whitelist = whitelist_module.whitelist;
	local special_patterns = whitelist_module.special_patterns;
	local DNB_special_patterns = whitelist_module.DNB_special_patterns;
	local DNB_template_names = whitelist_module.DNB_template_names;

	if 10 == namespace then
		return '';																-- automatic form of |no-tracking=yes; TODO: is this too broad?
	end

	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 (special_patterns) do							-- spin through the spcial patterns and try to match
			if anchor_id:match (pattern) then
				return '';
			end
		end

		for _, dnb_t in ipairs (DNB_template_names or {}) do					-- getting desparate now, are there any DNB templates? DNB_template_names may be nil; empty table prevents script error
			if template_list[dnb_t] then										-- if the article has this DNB template
				for _, pattern in ipairs (DNB_special_patterns) do				-- spin through the DNB-specifiec wildcard patterns
					if anchor_id:match (pattern) then							-- and attempt a match
						return '';												-- found a match
					end
				end
			end
		end

		msg = 'no target: ' .. anchor_id;										-- anchor_id not found
		category = '[[Kategorija:Harv in Sfn no-target napake]]';

	elseif 1 < tally then
		msg = 'multiple targets (' .. tally .. '×): ' .. anchor_id;				-- more than one anchor_id in this article
		category = 0 == namespace and '[[Kategorija:Harv in Sfn multiple-target napake]]' or '';								-- only categorize in article space
		return '<span class="error harv-error" style="display: inline; font-size:100%"> ' .. args.template .. ' napaka: ' .. msg .. ' ([[:Kategorija:Harv in Sfn napake predlog|pomo?]])</span>' .. category;
	end

--	category = 0 == namespace and '[[Kategorija:Harv in Sfn napake predlog]]' or '';	-- only categorize in article space
	category = 0 == namespace and category or '';								-- only categorize in article space

--use this version to show error messages
--	return msg and '<span class="error harv-error" style="display: inline; font-size:100%"> ' .. args.template .. ' error: ' .. msg .. ' ([[:Kategorija:Harv in Sfn napake predlog|pomo?]])</span>' .. category or '';
--use this version to hide error messages
	return msg and '<span class="error harv-error" style="display: none; font-size:100%"> ' .. args.template .. ' error: ' .. msg .. ' ([[:Kategorija:Harv in Sfn napake predlog|pomo?]])</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,
	};
皮草是什么意思 太君是什么意思 慢性病是什么意思 酪氨酸酶是什么东西 粽子的叶子是什么叶
平起平坐是什么动物 脾肾阳虚吃什么中成药最好 糖尿病不能吃什么水果 什么是泥炭土 网拍是什么意思
嘱托是什么意思 大便颜色发黑是什么原因 来月经前头痛什么原因 马蹄什么季节上市 半夜会醒是什么原因
co是什么气体 流莺是什么意思 甲母痣是什么 正常白带是什么味道 肺结节吃什么药能散结
xl代表什么尺码hcv9jop5ns2r.cn 什么样的镜子hcv8jop2ns4r.cn ppi是什么weuuu.com 梦到发大水是什么意思chuanglingweilai.com 什么是焦距hcv8jop9ns2r.cn
己未五行属什么liaochangning.com 拘留所和看守所有什么区别hcv8jop4ns1r.cn 法国的国花是什么花hcv9jop7ns1r.cn 钠高是什么原因hcv9jop1ns1r.cn 见多识广是什么生肖hcv9jop4ns0r.cn
1月生日是什么星座hcv9jop3ns0r.cn 太息是什么意思hcv8jop5ns4r.cn 吃什么食物能养肝护肝hcv8jop0ns3r.cn 吃什么放屁多cj623037.com 荷花的寓意是什么hcv9jop2ns9r.cn
圣母娘娘是什么神hcv9jop5ns3r.cn me too是什么意思hcv8jop5ns1r.cn 文定之喜是什么意思hcv7jop9ns3r.cn 老是嗜睡是什么原因hcv8jop8ns5r.cn 否极泰来是什么生肖tiangongnft.com
百度