卵泡不破是什么原因| 梦见蝎子是什么意思| 月经每个月都提前是什么原因| 汗斑用什么药擦最有效| 一命呜呼是什么意思| 扁桃体2度是什么意思| 炖牛肉不能放什么调料| 柿子和什么不能一起吃| 想一出是一出什么意思| 这什么意思| 芝麻分是什么意思| 脱发是什么原因引起的| 19岁属什么生肖| 医生为什么用肥皂洗手| 异国他乡的意思是什么| 女生下体长什么样子| 正方形体积公式是什么| 桃园三结义是什么生肖| 宁的五行属性是什么| 自来鸟是什么兆头| 三围是什么| 舌头发麻看什么科| 什么样的男人值得托付终身| 胃胀想吐吃什么药| 石女什么意思| 一什么桥| 双侧卵巢显示不清是什么意思| 2222是什么意思| 经常眩晕是什么原因引起的| 儿童流鼻血什么原因引起的| 什么菜| 大便有粘液是什么原因| manu是什么意思| 遗精是什么原因引起的| 拉肚子喝什么药| 什么是省控线| 发烧为什么感觉冷| 什么吃蚊子| 五险一金和社保有什么区别| delvaux是什么牌子| 上环后同房要注意什么| 灯笼裤配什么鞋子好看| 胃痉挛有什么症状表现| 你喜欢吃什么用英语怎么说| a216是什么材质| 什么血型生出o型血| tfboys什么意思| 手上长水泡痒用什么药| 子宫内膜6mm意味着什么| 区长什么级别| 免疫系统由什么组成| 床头朝什么方向是正确的| 精神洁癖是什么意思| 7.23是什么星座| 50是什么意思| 微创是什么| 大便出血是什么原因引起的| 什么东西泡脚减肥| 梦见打死狗有什么预兆| 流清水鼻涕是什么感冒| 静候佳音是什么意思| 过氧化氢弱阳性什么意思| 什么是类风湿| 红光对皮肤有什么作用| hpvhr阳性什么意思| 不割包皮有什么影响吗| 洄游是什么意思| 星五行属性是什么| 胚由什么组成| 什么人不能吃海带| 为什么萤火虫会发光| 快走对身体有什么好处| 心跳加快是什么病| land rover是什么车| 戛然而止是什么意思| 学美容要学些什么| 沉香是什么东西| 狗狗产后吃什么下奶多| 每年什么时候最热| 额头上长痘是因为什么| 日本为什么偷袭珍珠港| 喝豆浆拉肚子什么原因| ala是什么| 超声波是什么原理| 文笔是什么意思| 什么是浅表性胃炎| 二月九号是什么星座| 火车代表什么生肖| image是什么意思| 83岁属什么生肖| 福肖指什么生肖| 长胸毛的男人代表什么| 聚乙二醇是什么东西| 大圆脸适合什么发型| 什么的生长| 七八年属什么生肖| 低血钾是什么病| 孩子经常流鼻血是什么原因| 龙井是什么茶| 桂花树施什么肥| 手术后发烧是什么原因| camel是什么颜色| 女人阳虚吃什么药效果最好| 爱情是个什么东西| 眼拙是什么意思| 扁桃体发炎看什么科| 梦见老公不理我是什么意思| 男性尿路感染有什么症状| amiri是什么牌子| 婴儿吐奶是什么原因| 生化什么意思| 煮肉放什么调料| 三元是什么意思| 长红痣是什么原因| 尿酸高什么不能吃| 吃桑葚对身体有什么好处| 鱼不能和什么一起吃| 开业送什么礼物好| 胸口疼挂什么科| 舍利子到底是什么| 芙蓉花是什么花| 副书记是什么级别| 正财代表什么| 血糖高吃什么药最好| 元宝是什么意思| 做爱时间短吃什么药好| 拔牙能吃什么| 在是什么意思| 不怕流氓什么就怕流氓有文化| 眼震电图能查什么病| 不苟言笑的苟是什么意思| EE什么意思| 跑完步头疼是为什么| 牙结石不除有什么危害| 梦到火是什么意思| 单硬脂酸甘油酯是什么| 干眼症缺乏什么维生素| 古代的面首是什么意思| 打乙肝疫苗需要注意什么| 6.28什么星座| 明朝北京叫什么| cenxino手表是什么牌子| A型血为什么是完美血型| 两性关系是什么意思| 护资成绩什么时候出| 智齿是什么样的| 什么叫尿潜血| 吕洞宾代表什么生肖| 北瓜是什么瓜| 人造石是什么材料做的| 什么不惧| 牛骨煲什么汤对儿童好| 会阴是什么部位| 1980年属什么| 洗涤是什么意思| 幻听是什么症状| 惊醒是什么意思| 什么血型好| 布偶猫长什么样| 211什么意思| 科技布是什么材质| 脑血栓是什么意思| 大腿根部痛是什么原因| 2004年是什么生肖| 什么是核心期刊| 狗狗胰腺炎吃什么药| 陶渊明是什么朝代的| 胃不消化吃什么药效果最好| 痞块是什么意思| ems是什么意思| 感觉不到饿是什么原因| 部首和偏旁有什么区别| 口腔扁平苔藓吃什么药好得快| 来月经前有褐色分泌物是什么原因| 城隍爷叫什么名字| 蒸鱼豉油是什么| 乔峰和洪七公什么关系| 遗精什么意思| 狐狸是什么科| 体内湿热吃什么中成药| 爱情是什么样| 私奔是什么意思| 三国之前是什么朝代| 谩骂是什么意思| 什么是血沉| 荨麻疹为什么晚上起| 什么是白矮星| 膝盖疼痛什么原因| 妇科衣原体是什么病| 鹦鹉什么时候下蛋| 睡觉做噩梦是什么原因| 汗疱疹是什么原因引起的| 塔罗牌是什么| 榴莲什么味道| 玉鸟吃什么饲料好| 脸颊两边长痘痘是什么原因引起的| 做梦梦到踩到屎是什么意思| 降血糖吃什么药| 天下乌鸦一般黑是什么意思| 复方丹参片治什么病| 血糖高喝什么茶| 屋上土是什么意思| 私处长痘痘是什么原因| 阴郁是什么意思| 麦芽糊精是什么| 什么时候绝经| 什么叫唐卡| 下午吃什么饭| 吃一个海参相当于吃了什么| 为什么不建议吃大豆油| 食是代表什么生肖| 什么叫静脉曲张| 药流可以吃什么水果| 喉咙痛吃什么药| 老花眼有什么办法可以恢复| 脚脱皮用什么药膏有效| 临幕是什么意思| 女生diy什么意思| 易激惹是什么意思| 26岁属什么生肖| 红色裤子搭配什么颜色上衣| 血压低容易得什么病| 低脂牛奶适合什么人喝| 口加才是什么字| 谨记教诲是什么意思| 谷丙转氨酶是什么| 抽血化验挂什么科| 血糖高要忌口什么| 肺结核通过什么途径传染| 女性腰疼是什么原因| 腿硬邦邦的是什么原因| coat是什么意思中文| 右半边头痛是什么原因| 实属什么意思| 无机磷测定是检查什么| 怀孕吃什么水果最好| 强烈的什么| 高密度脂蛋白低是什么原因| 11年属什么| 宫颈活检lsil是什么病| 刷墙的白色涂料叫什么| 什么水果不含糖| 寄生虫长什么样子| 孕妇吃什么水果对胎儿好| 胚胎是什么意思| 怀孕吃什么宝宝会白| 什么字永远写不好| 头晕什么原因引起的| 食管裂孔疝是什么原因造成的| 撤退性出血是什么意思| 冒泡是什么意思| 丝瓜长什么样| 吝啬的意思是什么| 人乳头病毒是什么意思| 地藏菩萨的坐骑是什么| 万马奔腾是什么生肖| 出家当和尚有什么要求| 8月8号是什么日子| 肝掌是什么原因引起的| 松针土适合种什么花| 结膜出血用什么眼药水| 曹操字什么| 脸发麻是什么原因| 生长纹是什么原因| 百度Mazmuna ge?iň

2月份豪华品牌销量出炉 凯迪拉克成最大黑马

Wikipediya, erkin ensiklopediya
百度 从东边窜进来的,速度很快,我还以为是周围谁家养的狗。

Bu modul ü?in resminamalar Module:Footnotes/doc sahypasynda d?redilip bilner

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,
	};
什么美白效果最好最快 衣冠禽兽什么意思 心慌出虚汗是什么原因 普洱茶什么季节喝好 为什么不能下午看病人
今天吃什么随机 开心果是什么树的果实 身体不适是什么意思 笑刑是什么 前列腺ca是什么意思
缺铁性贫血吃什么食物好 什么洗发水好 阿贝数是什么意思 房颤有什么危害 下连是什么意思
早上喝蜂蜜水有什么好处 吃什么东西减肥最快 63岁属什么 什么叫一个周期 五月十四号是什么情人节
牛大力和什么泡酒壮阳mmeoe.com 湿疹是什么样的症状hcv8jop9ns8r.cn 狗狗有什么品种hcv7jop9ns7r.cn 2018年属什么hcv8jop4ns5r.cn 产前诊断是检查什么hcv8jop7ns9r.cn
两小无猜什么意思hcv8jop1ns1r.cn 飞的第一笔是什么jasonfriends.com 元气是什么意思hcv9jop3ns4r.cn 受戒是什么意思wuhaiwuya.com 什么样的歌声hcv8jop6ns5r.cn
和可以组什么词hcv8jop6ns0r.cn 祈是什么意思hcv9jop4ns6r.cn 花柳病是什么病hcv9jop7ns4r.cn 心肾不交吃什么中成药hcv7jop5ns2r.cn 梦到鸡是什么意思hcv8jop5ns5r.cn
后背发热是什么原因hcv9jop8ns3r.cn 夏祺是什么意思hcv7jop6ns0r.cn 负荆请罪是什么意思hcv7jop5ns0r.cn 卢靖姗是什么混血hcv9jop2ns4r.cn 调理是什么意思hcv8jop1ns4r.cn
百度