三千烦恼丝什么意思| 肝火旺盛吃什么药效果最好| 下嘴唇溃疡是什么原因| 感冒是什么意思| 婴儿放屁多是什么原因| 羊肉炖什么补肾壮阳| 皂基是什么| 梅毒通过什么传播| 什么是桥本病| 附件炎吃什么药| 缺心眼是什么意思| 科技皮是什么皮| 风代表什么数字| 玩家是什么意思| 纯净水和矿泉水有什么区别| 遇难是什么意思| 维生素b6是什么| gccg是什么牌子| 血尿是什么原因引起的| 太平公主叫什么名字| 艾灸为什么不能天天灸| 75岁属什么| 中国的国花是什么花| 来大姨妈喝酒有什么影响| 猪横利是什么| 风湿性心脏病吃什么药| 阴差阳错代表什么生肖| 治疗勃起困难有什么药| 什么水果是寒性的| 月球表面的坑叫什么| 什么是脑白质病| 宫颈炎用什么药物治疗比较好| 炎性结节是什么意思| 缺磷吃什么食物好| 门槛什么意思| 什么油炒菜好吃| 乳糖不耐受可以喝什么奶| 180度是什么角| 变更是什么意思| 子宁不嗣音什么意思| 窒息是什么意思| 清明是什么意思| balenciaga什么品牌| 便秘喝什么| 砚台是什么| 脚软没力气是什么原因引起的| 界限性脑电图是什么意思| 重庆市长是什么级别| 什么东西能补肾壮阳| 默哀是什么意思| 自来熟是什么意思| 周海媚什么病| 拔完智齿后需要注意什么| 平胸是什么原因导致的怎样解决| 魔芋爽是什么做的| 感冒咳嗽吃什么水果好| 桑葚搭配什么泡水喝最好| 肛门松弛是什么原因| 菠萝为什么要用盐水泡| 什么是乙肝| 苦胆是什么| 必迈跑鞋什么档次| 本来无一物何处惹尘埃是什么意思| 皮肤长小肉粒是什么原因| RH阳性什么意思| nsfw什么意思| 静的部首是什么| 糖尿病吃什么水果比较好| ellesse是什么牌子| 合菜是什么| 友女是什么意思| 失眠吃什么食物最有效| 脸色暗沉发黑什么原因| 乳腺结节有什么危害| 老是掉头发是什么原因| 眼睛痒流泪是什么原因| 小孩子注意力不集中是什么原因| on是什么牌子| mophie是什么牌子| 雨后的彩虹像什么| 儿童感冒咳嗽吃什么药| 九寨沟在四川什么地方| 巴结是什么意思| 济公是什么罗汉| 治飞蚊症用什么眼药水| 海螺不能和什么一起吃| 火麻仁是什么| 打不死的小强什么意思| 紫薇花什么季节开花| 寻麻疹是什么症状| 颈椎病用什么枕头最好| 四面楚歌什么意思| 0中间有一横是什么字体| 一视同仁什么意思| 一次不忠终身不用什么意思| 姐姐的女儿应该叫什么| 肠镜检查前需要做什么准备工作| 为什么会得带状疱疹| 胆囊炎可以吃什么| 氟化钠是什么| 黑眼圈是什么病| 深覆合是什么样子的| 苗字五行属什么| 成双成对是什么意思| 稻谷什么时候成熟| 白化病是一种什么病| 腰椎退行性变是什么意思| 孝道是什么意思| 梦见买苹果是什么征兆| 空调病是什么症状| 负离子是什么| snr是什么意思| 白发多的原因是什么| 有什么园| 钾血症是什么病| 什么地回答| karen是什么意思| 为什么女人阴唇会变黑| 梦见蛇是什么征兆| 县检察长是什么级别| 一蹴而就什么意思| 12月7号是什么星座| 低烧是什么病的前兆| 蛋白粉有什么用| 阴道为什么会排气| 低血压有什么症状| 手癣用什么药膏效果好| 女人总犯困是什么原因| 红糖有什么功效| ricoh什么牌子| 尿酸高是什么原因| 开光的手串有什么禁忌| 嘴角发黑是什么原因| 苏轼为什么反对王安石变法| 近视散光是什么意思| 肾虚吃什么| 富字五行属什么| 脯氨酸氨基肽酶阳性是什么意思| 鸭肫是鸭的什么部位| dha是补什么的| 庄周梦蝶是什么意思| 身体燥热是什么原因| 200年属什么生肖| 验血糖挂什么科| 五粮液什么香型| 什么的虾| 槟榔为什么上瘾| 耳朵后面疼是什么原因| 喷昔洛韦乳膏治什么| 头疼头胀是什么原因| 肌无力有什么症状| 妇科病吃什么药| 6月15日什么星座| 人和是什么意思| 刘邦是什么星座| 怎么知道自己对什么过敏| 尿道炎是什么症状| 牛逼是什么| 内分泌代谢科是看什么病的| 虎属什么五行| 心尖尖是什么意思| 旭日东升是什么生肖| 山楂和什么泡水喝减肥效果最好| 早上口干舌燥是什么原因| 时柱亡神是什么意思| 瓜子脸适合什么刘海| pu是什么皮| 一喝水就尿多是什么原因| 女生左手无名指戴戒指什么意思| 梦见跟妈妈吵架是什么意思| 胃不好的人适合吃什么水果| 罗汉果泡水有什么好处| 凯字五行属什么| 老鼠吃什么| 中国文字博大精深什么意思| 想请假找什么理由好| 什么叫积阴德| 别开生面是什么意思| 炒菜用什么油比较好| 屈光不正什么意思| 壁虎是什么类动物| 返酸水吃什么药| 白蛇是什么蛇| d二聚体是检查什么的| 教授是什么级别| efg是什么意思| 应无所住什么意思| 苦口婆心是什么生肖| nba季后赛什么时候开始| 项羽是什么生肖| 静脉采血检查什么| 台甫是什么意思| 迟缓是什么意思| 有毒是什么意思| 梅毒和艾滋病有什么区别| 什么网站可以看黄色视频| 梦见捞鱼是什么意思| 风湿是什么原因造成的| 狭鳕鱼是什么鱼| 揩油是什么意思| 烤麸是什么做的| 11月29号什么星座| 偏头痛什么原因引起| 什么东西可以减肥| 诸葛亮为什么气死周瑜| hp是阳性什么意思| 膝盖疼痛什么原因| 什么是有意义的东西| bun什么意思| 竹者念什么| 谷氨酸钠是什么东西| 心脏骤停是什么原因引起的| ca什么意思| 针灸后需要注意什么| 芒果什么人不适合吃| 卡他症状是什么意思| 人日是什么意思| 霉菌性阴道炎吃什么药| 喝莓茶对身体有什么好处| 橡木色是什么颜色| 莽是什么意思| 头孢什么样子图片| 什么是僵尸肉| 懿怎么读 什么意思| uniqlo是什么牌子| 喝啤酒尿多是什么原因| 老人适合喝什么茶| 比重是什么| 银耳汤有什么功效| 午夜梦回是什么意思| 舂米是什么意思| 腋下大量出汗是什么原因| 梦见很多人是什么意思| 新疆有什么水果| 血沉是检查什么的| 巴基斯坦是什么人种| 涵字属于五行属什么| 小壁虎吃什么| 热伤风感冒吃什么药| 牙齿痛用什么药| 前脚底板痛是什么原因| 儿童肚子疼挂什么科| 尿酸低会引发什么症状| 太阳穴痛是什么原因| 男生被口什么感觉| close是什么意思| 月经淋漓不尽什么原因| 喝茶叶水有什么好处和坏处| 2004是什么年| 什么叫西米| 多动症是什么引起的| 癌胚抗原是什么意思| 善变是什么意思| 七月十九是什么星座| 为什么一分钟就出来了| 跑男什么时候播出| 西梅什么时候成熟| 鸡尖是什么| 吃虾不能和什么一起吃| mep是什么意思| 吃什么油对身体好| 双侧腋下见淋巴结什么意思| 低血糖是什么引起的| 跑步穿什么衣服| 百度Kontent qismiga o?tish

身体有这种肿块当心皮肤癌皮肤癌肿块淋巴

Vikipediya, erkin ensiklopediya
百度 《办法》要求残疾人服务机构接收残疾人,要对其基本情况进行评估,应当与接受服务的残疾人或其代理人签订具有法律效力、权责明晰的服务协议,并规定了服务协议一般应当载明的10个事项,从而促进残疾人服务机构提高管理的程序化、规范化、科学化水平。

}}


require('Module:No globals');
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 = ", ss.&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 = '';

	elseif 1 < tally then
		msg = 'multiple targets (' .. tally .. '×): ' .. anchor_id;				-- more than one anchor_id in this article
		category = 0 == namespace and '' 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 '' 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 .. ' ([[:Category:Harv and Sfn template errors|help]])</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 .. ' ([[: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:Manba/MU1/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:Manba/MU1/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.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 '';
		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,
	};
人体最大的器官是什么 儿童便秘吃什么最快排便 尿蛋白高有什么危害 时光什么意思 珍珠有什么功效
丝状疣是什么样子图片 elsa是什么意思 一什么头巾 可什么意思 大便干燥一粒一粒的吃什么药
什么是出柜 6月底是什么星座 蜗牛的天敌是什么 经常打飞机有什么危害 早上起床口苦口干是什么原因
肝阳上亢是什么意思 脚上脱皮是什么原因 什么忙什么乱 运动后恶心想吐是什么原因 工作效率等于什么
骨折吃什么好的快luyiluode.com 许褚字什么hcv8jop6ns9r.cn 聊表心意什么意思zhongyiyatai.com 经常眨眼睛是什么原因hcv8jop2ns6r.cn 氢氧化钠是什么aiwuzhiyu.com
刘邦和项羽是什么关系hcv9jop2ns6r.cn 胃溃疡能吃什么hcv7jop7ns0r.cn 矫正视力是什么意思hcv8jop2ns5r.cn 婴儿头发长得慢是什么原因hcv9jop7ns0r.cn 天成是什么意思hcv7jop9ns9r.cn
什么原因导致脾虚hcv9jop3ns7r.cn 12305是什么电话hcv8jop1ns8r.cn 蒲公英的约定表达什么hcv8jop2ns1r.cn 血常规检查什么项目hcv7jop6ns0r.cn 胃一阵一阵绞痛是什么原因imcecn.com
04年属什么hcv9jop1ns7r.cn 手术前吃什么补充营养hcv9jop1ns0r.cn 蛋白粉有什么功效hcv9jop4ns1r.cn 喝什么水减肥最快hcv9jop4ns9r.cn 一什么阳光填量词hcv9jop2ns3r.cn
百度