柳树代表什么生肖| 劳作是什么意思| 茵陈是什么| 甲状腺球蛋白低说明什么| 三班两倒是什么意思| 煮花生放什么调料| 梦见邻居是什么意思| 尿道炎吃什么药好得快| 碧潭飘雪是什么茶| 什么的娃娃| 渗透压低是什么意思| 杨紫属什么生肖| 1961年属什么| 来月经为什么会拉肚子| 梦到男朋友出轨了预示什么意思| 孤魂野鬼是什么生肖| 胃出血吃什么药| 10月28号是什么星座| 什么是强迫症有哪些表现| 三十如狼四十如虎什么意思| 荣誉的誉是什么意思| 痢疾是什么原因引起的| vans属于什么档次| 胸口疼应该挂什么科| 什么叫地包天| 70年的狗是什么命| 10月25号是什么星座| 145什么意思| 打了封闭针后要注意什么事项| 奇花异草的异什么意思| 飞机什么时候停止登机| 2002年什么年| 为什么会得人工荨麻疹| 尿路感染用什么药好| 中文是什么意思| 鞘是什么意思| 双子座和什么星座最配| 牙齿黄用什么牙膏| 无痕是什么意思| 为什么会得hpv| 秀女是什么意思| 脸发黄什么原因| 肺与什么相表里| 爬是什么结构| 雄脱是什么意思| 万象更新是什么意思| 舌头上有黑点是什么原因| 什么东西越生气越大| 耳后淋巴结肿大吃什么消炎药| 消化性溃疡吃什么药好| 属猪的本命佛是什么佛| 什么蘑菇有毒| 壁立千仞无欲则刚是什么意思| 睾丸痛吃什么消炎药| 脾虚吃什么好| 五月是什么星座的啊| 芒果对身体有什么好处| 灏字五行属什么| 陈皮治什么病| 肛裂出血和痔疮出血有什么区别| 中性粒细胞高说明什么| 彩礼是什么意思| 缺铁性贫血吃什么药好| 莱昂纳多为什么叫小李子| 小动脉瘤是什么意思| 什么口服液补血补气最好| 这是什么颜色| 梦见入室抢劫意味什么| 日柱代表什么| 排卵期同房后要注意什么| 为什么长鸡眼| 1955年属羊的是什么命| 湿疹是什么病的前兆| 属鼠的本命佛是什么佛| 代发什么意思| 6月23日是什么星座| 什么药可以降肌酐| 胆固醇高是什么意思| 头经常晕是什么原因| 娃娃鱼吃什么| 当我们谈论爱情时我们在谈论什么| 宝宝有口臭是什么原因引起的| 经络是什么| 喝水经常呛到是什么原因| 请教意思是什么| 黄埔军校现在是什么学校| 止咳吃什么药| 什么是电信诈骗| LC什么意思| 手肘关节疼痛什么原因| 为什么每次同房后都会尿路感染| 黄山毛峰属于什么茶| 蟾蜍吃什么| 用什么洗头白发能变黑| 乌龟吃什么蔬菜| 精华液是干什么用的| 番茄和西红柿有什么区别| 耳洞发炎流脓用什么药| 口气重是什么原因| 枭神夺食会发生什么| aosc医学是什么意思| 颈椎退变是什么意思| 低烧什么症状| 乙肝表面抗体阴性是什么意思| 赛诺菲是什么药| 闹心是什么原因导致的| 水晶绒是什么面料| 香蕉吃多了有什么坏处| 梦见抓鱼是什么意思| 泰山在什么地方| 公明仪属什么生肖| 啷个是什么意思| 女人40不惑什么意思| 壁立千仞无欲则刚是什么意思| 中国发明了什么| 黑五是什么时候| 一拃是什么意思| 山楂炖肉起什么作用| 力排众议是什么意思| 蛋白质有什么作用| 牙疼是什么原因导致的| 丧尸是什么意思| 白细胞低是什么意思| 幽门螺杆菌什么药最好| 大便陶土色是什么颜色| 2013年是什么年| 理气是什么意思| 经常头晕头疼是什么原因| 陪产假什么时候开始休| 为什么会突发脑溢血| 什么是本命年| 人和是什么意思| 无蒂息肉是什么意思| 伤口不愈合是什么原因| 欺世盗名是什么意思| 什么地唱| 先天性心脏病是什么原因造成的| NT是什么钱| alan英文名什么意思| 脂肪肝轻度是什么意思| 王字旁的字与什么有关| 血糖看什么指标| 烟酒不沾的人什么性格| 龙男和什么生肖最配| 红霉素软膏有什么作用| 脑梗是什么引起的| 反洗钱是什么意思| 开导是什么意思| 脑梗吃什么药| 玉树临风是什么意思| 回归热是什么病| 阿斯伯格综合症是什么| 十二生肖代表什么花| 1998年属虎的是什么命| 头发不干就睡觉有什么危害| 头部麻木是什么征兆| 热得什么| 上朝是什么意思| 1987年属什么| cct是什么意思| 为什么手指会发麻| 传媒公司主要做什么| 甘草片不能和什么药一起吃| 人体缺钙吃什么补最快| 财年是什么意思| 嘘寒问暖是什么意思| 尖锐湿疣吃什么药| 368什么意思| 莆田荔枝什么时候成熟| 风五行属什么| seifini是什么牌子| 为什么要当兵| 鹿晗和邓超什么关系| 一声叹息是什么意思| 寿辰是什么意思| 子宫内膜炎有什么症状| 农历六月十七是什么星座| 蚂蚁喜欢吃什么食物| 头晕想吐是什么症状| 缅怀是什么意思| 504是什么错误| 丹毒用什么抗生素| 1946年中国发生了什么| 胰腺不好吃什么食物好| 尿道发炎吃什么药| 结石什么东西不能吃| 小孩头发黄是什么原因| 自什么自什么| 子宫偏小是什么原因| 什么是躁郁症| 睡觉多梦是什么原因引起的| 累赘是什么意思| 自学成才是什么意思| 二十年是什么婚| bebe是什么牌子| 对牛弹琴是什么意思| 宫寒是什么引起的| 父母宫代表什么| 糖尿病吃什么好| na是什么| 什么狗最贵| 牛和什么属相最配| dvf是什么档次的牌子| 退翳什么意思| 他乡遇故知什么意思| 征信对个人有什么影响| 健康证都查什么| 无畏布施是什么意思| 梦见芹菜是什么意思| pu是什么| 伸什么缩什么| 广西是什么族| 明月对什么| 一月18号是什么星座| 奶粉中的opo是什么| 今年22岁属什么生肖| 孺子可教什么意思| 19时是什么时辰| 情人眼里出西施是什么意思| 碘缺乏会导致什么疾病| 自来水是什么水| 甲亢不能吃什么| 人突然瘦了要检查什么| 耐人寻味什么意思| 蝴蝶有什么寓意| 脱髓鞘病变是什么意思| 油菜花什么颜色| 茼蒿不能和什么一起吃| 糖尿病人吃什么水果最好| 尿酸高不能吃什么水果| 发烧咳嗽挂什么科| 用盐洗脸有什么好处| 橄榄油的好处和坏处是什么| 卑职是什么意思| 97年属什么的生肖| 脚底发红是什么原因| 肥胖纹什么样子| 现在去贵州穿什么衣服| 5月19号是什么星座| 后背疼是什么病的前兆| 减肥吃什么肉类| notice是什么意思| 子宫肌层回声欠均匀是什么意思| 中心句是什么意思| 鲜红的什么| 五点是什么时辰| 甲状腺tsh高说明什么| 什么东西最隔音| 2012什么年| 宾至如归是什么意思| 肉身成圣是什么意思| oa是什么意思| 海葡萄是什么东西| 加盟店是什么意思| 肺部有结节要注意什么| 吃什么补维生素D效果最好| 月经不停吃什么药| 梦见鸡死了是什么预兆| 四面楚歌是什么意思| 咽喉痛什么原因| 证件照一般是什么底色| 木字旁加差是什么字| 结界是什么意思| 舌苔又白又厚是什么原因| 百度Jump to content

浙江:绍兴市“护苗2017”专项行动取得阶段性成效

From Wikipedia, the free encyclopedia
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 = {
    group = '',
	bracket_left = '',
	bracket_right = '',
	bracket_year_left = '',
	bracket_year_right = '',
	postscript = '',
	page = '',
	pages = '',
	location = '',
	page_sep = ", p.&nbsp;",
	pages_sep = ", pp.&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/sandbox');
	local anchor_id_list = anchor_id_list_module.anchor_id_list;
	local article_whitelist = anchor_id_list_module.article_whitelist;
	local template_list = anchor_id_list_module.template_list;
    local citeref_patterns = anchor_id_list_module.citeref_patterns
	
	local whitelist_module = mw.loadData ('Module:Footnotes/whitelist');
	local whitelist = whitelist_module.whitelist;

	local tally = anchor_id_list[anchor_id];									-- nil when anchor_id not in list; else a tally
	local msg;
	local category;

	if not tally then
		if args.ignore then
			return '';															-- if ignore is true then no message, no category
		end
		
		if article_whitelist and article_whitelist[anchor_id] then				-- if an article-local whitelist and anchor ID is in it
			return '';															-- done
		end
		
		local wl_anchor_id = anchor_id;											-- copy to be modified to index into the whitelist
		
		if args.year then														-- for anchor IDs created by this template (not in |ref=) that have a date
			if args.year:match ('%d%l$') or										-- use the date value to determine if we should remove the disambiguator
				args.year:match ('n%.d%.%l$') or
				args.year:match ('nd%l$') then
					wl_anchor_id = wl_anchor_id:gsub ('%l$', '');				-- remove the disambiguator
			end
		end		

		local t_tbl = whitelist[wl_anchor_id];									-- get list of templates associated with this anchor ID

		if t_tbl then															-- when anchor ID not whitelisted t_tbl is nil
			for _, t in ipairs (t_tbl) do										-- spin through the list of templates associated with this anchor ID
				if template_list[t] then										-- if associated template is found in the list of templates in the article
					return '';													-- anchor ID is whitlisted and article has matching template so no error
				end
			end
		end

        for _, pattern in ipairs(citeref_patterns) do                           -- load patterns for wrapper templates on this page
           if anchor_id:match(pattern) then                                     -- spin through the special patterns and try to match
              return ''
           end
        end
  

		msg = 'no target: ' .. anchor_id;										-- anchor_id not found
mw.log(msg)
        if namespace == 10 and not args.show then                               -- do not generate error message in template namespace
           return ''
        end
		category = '[[Category:Harv and Sfn no-target errors]]';

	elseif 1 < tally then
		msg = 'multiple targets (' .. tally .. '×): ' .. anchor_id;				-- more than one anchor_id in this article
mw.log(msg)
        if namespace == 10 and not args.show then                               -- do not generate error message in template namespace
           return ''
        end
		category = 0 == namespace and '[[Category:Harv and Sfn multiple-target errors]]' or '';								-- only categorize in article space
		return '<span class="error harv-error" style="display: inline; font-size:100%"> ' .. args.template .. ' error: ' .. msg .. ' ([[:Category:Harv and Sfn template errors|help]])</span>' .. category;
	end

--	category = 0 == namespace and '[[Category:Harv and Sfn template errors]]' or '';	-- only categorize in article space
	category = 0 == namespace and category or '';								-- only categorize in article space

-- display based on args.show (no display by default)
    local display = args.show and 'inline' or 'none'
    return msg and '<span class="error harv-error" style="display: '..display..'; font-size:100%"> ' .. args.template .. ' error: ' .. msg .. ' ([[:Category:Harv and Sfn template errors|help]])</span>' .. category or '';

end


--[[--------------------------< I S _ Y E A R >----------------------------------------------------------------

evaluates param to see if it is one of these forms with or without lowercase letter disambiguator:
	YYYY
	n.d.
	n.d.- (This will be suffixed by a letter when using author-date citations for the same author.)
	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?$',
	'^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.group = pframe.args.group or '';
	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={group=args.group, 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.group = pframe.args.group or '';									-- reference group
		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={group=args.group, name=name}, content=result});
end


--[[--------------------------< S F N R E F >------------------------------------------------------------------

implements {{sfnref}}

]]

local function sfnref (frame)
	local args = getArgs (frame);
	local out = {};
	
	for i=1, 5 do																-- get the first five args if there are five args
		if args[i] then
			out[i] = args[i];
		else
			break;																-- less than 5 args break out
		end
	end
	
	if 5 == #out then															-- when we have seen five args there may bemore
		local i = 6;															-- initialize the indexer to the sixth positional parameter
		while args[i] do														-- in case there are too many authors loop through the authors looking for a year
			if is_year (args[i], args) then										-- if a year
				out[5] = args[i];												-- overwrite whatever was in args[5] with year
				break;															-- and abandon the search
			end
			i = i + 1;															-- bump the indexer
		end
	end
	
	return mw.uri.anchorEncode ('CITEREF' .. table.concat (out));
end


--[[--------------------------< E X P O R T E D   F U N C T I O N S >------------------------------------------
]]

return {
	harvard_citation = harvard_citation,
	sfn = sfn,
	sfnm = sfnm,
	sfnref = sfnref,
    target_check = target_check,
	};
为什么会长血管瘤 排卵期是什么时候开始算 术后改变是什么意思 什么生肖最旺鸡 丑小鸭告诉我们一个什么道理
什么小吃最火爆最赚钱 为什么叫买东西不叫买南北 什么叫世家 鳞状上皮增生是什么意思 落魄是什么意思
鳖孙是什么意思 书店里买不到什么书 标题是什么意思 花斑癣用什么药膏好 测子女缘什么时候到来
什么人容易得精神病 月经提前量少是什么原因 宝宝肤专家软膏主要治什么 gg是什么牌子 经常呕吐是什么原因
6月19日什么星座hcv8jop4ns1r.cn 什么是辛辣刺激性食物hcv9jop5ns9r.cn 什么情况下安装心脏起搏器hcv9jop6ns8r.cn 缸垫呲了什么症状hcv9jop0ns4r.cn 生源地是什么意思xinjiangjialails.com
为什么日语hcv9jop6ns7r.cn 天是什么生肖wmyky.com 藕不能和什么一起吃hcv9jop3ns5r.cn 三叉戟是什么意思hcv8jop0ns3r.cn 失业是什么意思beikeqingting.com
头发软化和拉直有什么区别hcv7jop6ns4r.cn 什么相处mmeoe.com 肝纤维化是什么意思hcv9jop0ns5r.cn 血小板降低是什么病hcv7jop4ns6r.cn 银消病用什么药效果最好hcv8jop8ns2r.cn
假卵是什么样子的xinmaowt.com 闭目养神什么意思hcv9jop0ns5r.cn ko是什么意思啊baiqunet.com 阳痿是什么原因引起的hkuteam.com 什么狗不掉毛适合家养hcv9jop0ns0r.cn
百度