一什么金光| 营养科都检查什么项目| 直的是什么意思| 胃痛挂什么科| 腿麻是什么原因引起的| 画蛇添足什么意思| 黄体酮低吃什么补得快| 人参归脾丸和归脾丸有什么区别| 久违什么意思| 什么是阿尔兹海默症| 血糖高吃什么中药好| 肛门瘙痒用什么药膏好| 连衣裙配什么鞋子好看| 尿路感染检查什么项目| 吃什么水果下火| ta代表什么| 下午茶一般吃什么| 7月29号是什么星座| 2月8号什么星座| 双侧瞳孔缩小见于什么| 乳液是什么| 膝关节痛什么原因| 脖子痛什么原因| 能的偏旁是什么| 外围是什么意思| 劳力士手表什么档次| 决明子是什么| 反式脂肪是什么意思| 头顶一阵一阵疼是什么原因| 985什么意思| 3月31号什么星座| 减肥可以吃什么零食| 胃袋是什么| 尿频是什么原因| 孕妇喝什么汤最好最有营养| 失眠是什么症状| 老气横秋什么意思| 梦到生男孩有什么预兆| 男孩子什么时候刮胡子| 小便失禁是什么原因男性| 水代表什么数字| 狗肉配什么菜好吃| 多囊卵巢是什么原因造成的| 纯洁是什么意思| 膝盖后面叫什么| 贫血缺什么| ast什么意思| 眼睑肿是什么原因| 防晒霜和防晒乳有什么区别| 醉酒第二天吃什么才能缓解难受| 皮肤瘙痒用什么药最好| 血糖低是什么原因引起的| 屁股疼是什么原因| 公分是什么单位| 劲头是什么意思| 甲钴胺不能和什么药一起服用| 股癣用什么药膏好得快| 二月十号是什么星座| 经期吃榴莲有什么好处| 女人戴什么手串辟邪| 送长辈什么礼物好| 通草长什么样图片| 产后42天复查挂什么科| 什么牌子的裤子质量好| 脑白质疏松症是什么病| 甘油三酯是指什么| 幽门杆菌有什么症状| 大象是什么意思| 包茎挂什么科| 柠檬水有什么好处| 巩固是什么意思| 做梦梦见水是什么意思| mac是什么牌子口红| us检查是什么意思| 四月份是什么星座| 挫败感是什么意思| 窗口期什么意思| 虎是什么结构| 10月1日是什么日子| 辅警是什么编制| 眼睛充血用什么眼药水| 新生儿脸上有小红点带白头是什么| 降钙素原高是什么原因| 什么可以治早泄| AX是什么意思| 英国用什么货币| 甲亢是一种什么病严重吗| 为什么会阑尾炎| 什么时候会怀孕| 面包虫吃什么| 脂蛋白磷脂酶a2高说明什么| 梅毒通过什么传播| vmax什么意思| bg是什么意思| 红色裤子搭配什么颜色上衣| 男人吃秋葵有什么好处| 为什么手脚冰凉还出汗| 肚子胀不消化吃什么药| 甲钴胺片主治什么病| 梦到老虎是什么意思| clot什么牌子| 小孩下面痒用什么药| 眼花是什么原因引起的| 同位素是什么| 贪吃的动物是什么生肖| 天天射精对身体有什么危害| 合作医疗是什么| 三焦经在什么位置| 什么是户籍所在地| 澳门什么时候回归祖国| 规格型号是什么意思| 为什么早射| 什么是撸管| 实性结节是什么意思| 什么什么的天空| dw手表属于什么档次| 经常肚子疼拉肚子是什么原因| 重症肌无力用什么药| 2001年属蛇的是什么命| 胡萝卜不能和什么一起吃| 窗口期什么意思| 异什么同什么| 姓兰的是什么民族| 悻悻然是什么意思| 冲鼠煞北是什么意思| 带状疱疹有什么症状| 姨妈老是推迟是为什么| 养心吃什么食物好| 世界上最长的蛇是什么| 加速度是什么意思| 怕热出汗多是什么原因| 什么时候怀孕几率高| NPY什么意思| gy是什么意思| 猪八戒原名叫什么| 梦到吃饭是什么意思| 输血四项检查是什么| 耿耿什么| 总是拉稀是什么原因| 中国民间为什么要吃腊八粥| 脑门出汗多是什么原因| 晚上为什么不能剪指甲| 葡萄糖粉适合什么人喝| 孕妇吃鸡蛋对胎儿有什么好处| 乳腺增生吃什么| 下葬有什么讲究或忌讳| 外周动脉僵硬度增高什么意思| 口腔溃疡白色的是什么| 橡皮擦是什么材料做的| 霉菌是什么原因感染的| 打瓜是什么瓜| 清凉的什么| 甲钴胺治疗什么病| 缺血吃什么补血最快| 草木皆兵的意思是什么| 1977年属蛇是什么命| 258是什么意思| 无锡为什么叫无锡| 2017属什么| 晒背什么时候最佳时间| 什么是房补| ct平扫能检查出什么| 小儿感冒吃什么药| 庚子是什么时辰| 子宫内膜2mm说明什么| 早餐吃什么有营养| 71年的猪是什么命| 荨麻疹要注意什么| 肚子突然变大是什么原因| 暗代表什么生肖| 属狗的什么命| 召力念什么| 中性粒细胞数目偏高是什么意思| 生肖排第六是什么生肖| 手脚热吃什么药效果好| 卯宴席是什么意思| 1980年是什么命| 表彰是什么意思| 美国报警电话为什么是911| 胎儿宫内缺氧孕妇有什么症状| 头孢主要治什么病| 人为什么会打呼噜| 九五至尊什么意思| 后羿属什么生肖| 鱼在鱼缸底部不动为什么| 拿的起放的下是什么意思| 国防部部长是什么级别| 吃什么可以淡斑| 今年42岁属什么生肖| 高血钾是什么意思| 神的国和神的义指的是什么| e-mail什么意思| 痔疮有什么影响| 217是什么意思| 乙肝病毒表面抗原阳性是什么意思| 傻白甜的意思是什么| 眼角长痘痘是什么原因| 舌头两侧溃疡吃什么药| 宁字五行属什么| 滇红属于什么茶| 猴子捞月是什么生肖| 贫血缺什么元素| 海是什么颜色| 西瓜禁忌和什么一起吃| 什么是僵尸肉| 半边脸疼是什么原因| 阑尾炎手术后可以吃什么水果| 金牛座和什么星座最不配| 真菌感染是什么意思| 龚是什么意思| 应景是什么意思| l是什么字| 偏头痛吃什么药见效快| 晚霞是什么颜色的| 勾引什么意思| 乌托邦什么意思| 女红是什么意思| 紫绀是什么症状| 青龙白虎是什么意思| 龟头有红点用什么药| 刀个刀个刀刀那是什么刀| 什么都别说| 曹洪是曹操的什么人| 89年的属什么| 肠胃出血有什么症状| 肩膀骨头响是什么原因| 吃坏东西肚子疼吃什么药| 部署是什么意思| 尿激酶的作用及功效是什么| 王维有什么之称| 骨折吃什么药恢复快| 女人得性瘾什么症状| 忙什么呢幽默的回答| 辣根是什么| 金钱能买来什么但买不来什么| 取环需要做什么检查| 长白头发了吃什么才能把头发变黑| 手指关节疼痛用什么药| 做梦梦见钓鱼是什么意思| rock是什么意思| 爸爸的表哥叫什么| 夏至未至是什么意思| 一什么手套| 试管移植后吃什么容易着床| 肾亏和肾虚有什么区别| 流觞是什么意思| 海军蓝是什么颜色| aqi是什么| 六月二七是什么星座| 阴茎勃起不硬吃什么| 吃什么药能让月经推迟| 樱花什么时候开| 8月6号是什么星座| 低血压吃什么可以补| 眼镜是什么时候发明的| 风湿性心脏病吃什么药| 黄斑病变是什么引起的| moss是什么意思| 什么时候出伏| 公顷是什么意思| 竹鼠吃什么| 不除外是什么意思| 人长寿的秘诀是什么| 古代医生叫什么| 百度Pojdi na vsebino

张志南常务副省长调研宁德市高速公路建设情况

Iz Wikipedije, proste enciklopedije
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,
	};
黄历冲生肖是什么意思 历史是个什么玩意儿 脊柱炎是什么症状 yuri是什么意思 规则是什么意思
河粉是什么 天蝎座是什么象星座 长疱疹是什么原因 为什么地球是圆的 blush是什么颜色
为难是什么意思 熥是什么意思 胃息肉吃什么药治疗 风湿关节炎用什么药 膝盖疼挂什么科室
早上9点是什么时辰 腰椎挂什么科室 什么吃草吞吞吐吐歇后语 胃炎吃什么药好使 肾素高说明什么
脚踩棉花感见于什么病hcv9jop6ns1r.cn 6像什么hcv8jop2ns7r.cn 什么是包皮过长hcv9jop0ns0r.cn 有趣的什么填空hcv9jop6ns3r.cn 哪吒妈妈叫什么hcv8jop3ns8r.cn
什么的琥珀hcv7jop7ns4r.cn 脂蛋白a高是什么原因hcv8jop8ns6r.cn 肾虚吃什么药最有效hcv9jop2ns8r.cn 高同型半胱氨酸血症吃什么药baiqunet.com pdm是什么意思hcv9jop0ns4r.cn
肾阴虚是什么意思hcv9jop6ns4r.cn 四川代表什么生肖gysmod.com 眼皮红肿是什么原因hcv9jop6ns7r.cn 心态好是什么意思0735v.com 爱豆什么意思luyiluode.com
胃溃疡是什么意思hcv7jop9ns8r.cn 祥林嫂是什么样的人zhongyiyatai.com 绀是什么意思hcv8jop7ns6r.cn 自然流产是什么症状bjhyzcsm.com 7.7是什么星座hcv9jop0ns1r.cn
百度