高等院校是什么意思| 台卡是什么| 疣是什么样子图片| 不是经期有少量出血是什么原因| 马克定食是什么意思| 喝生姜水有什么好处| 烤瓷牙和全瓷牙有什么区别| joan什么意思| 女人补铁有什么好处| 老人手抖是什么病的预兆| 痤疮涂什么药膏| 什么叫切片| 吃什么好| 双相情感障碍是什么病| 昙花一现是什么生肖| 肌肉酸痛用什么膏药| u盘什么牌子好| 摆拍是什么意思| 非分之想是什么意思| 腺肌症吃什么食物好| 查肝炎做什么检查项目| 怀孕头三个月吃什么好| 婊是什么意思| 眼镜是什么时候发明的| 津是什么意思| 延迟是什么意思| 康庄大道是什么意思| 尿路感染是什么原因| 经常耳鸣是为什么| 丝瓜吃了有什么好处| 什么山什么水| 高血压高血糖挂什么科| 每天吃葡萄有什么好处和坏处| 下山虎是什么意思| 血糖高吃什么好能降糖| ppi是什么意思| 降结肠在什么位置| 拍证件照穿什么衣服| 骨折长骨痂有什么反应| 1946属什么生肖| 周边是什么意思| 阴历六月十五是什么日子| 后腰左侧疼痛是什么原因男性| 肠癌是什么症状| 抽筋缺什么| 黄风怪是什么动物| 妈妈吃什么帮宝宝排气| 桦树茸有什么功效| 慢性肠炎用什么药| 自媒体是什么| 间接胆红素偏高什么意思| 头孢加酒有什么反应| 林俊杰什么时候出道的| 为什么手脚老是出汗| 黄喉是牛的什么部位| 夜尿多是什么原因引起的| 便黑色大便是什么情况| 雅五行属什么| hp是什么牌子的电脑| 牙齿疼吃什么药| 水土不服是什么意思| 锋芒的意思是什么| 蛔虫是什么意思| 10月1日是什么日子| 秦始皇陵为什么不敢挖| 梦见着火是什么意思| 油面筋是什么做的| 一什么永什么成语| 穿匡威的都是什么人| 护理专业出来能干什么| 来大姨妈喝红糖水有什么作用| 肝风内动吃什么中成药| 突然晕厥是什么原因| 做核磁共振需要注意什么| 晚上睡觉磨牙是什么原因| 狗牯脑茶属于什么茶| 基本医疗保险包括什么| 第二个手指叫什么| 怀孕1个月有什么症状| 博字五行属什么| 肩膀疼挂什么科| 老是打嗝是什么病的征兆| 坚字五行属什么| 什么人不适合普拉提| 入殓师是干什么的| 耳朵痒是什么预兆| 食禄痣是什么意思| 神迹是什么意思| 谷氨酸高是什么原因| 4月23日是什么日子| 月经要来之前有什么症状| 睡觉脚抽筋是什么原因引起的| 一什么睡莲| 三月初八是什么星座| 肛门瘙痒用什么药| 上大厕拉出血是什么原因| 鲢鱼吃什么食物| 男人沉默了说明什么| 方巾是干什么用的| 手心脚心发热是什么原因引起的| 爱妃是什么意思| 梦见大山是什么预兆| 打喷嚏很臭是什么原因| 钙不能和什么一起吃| 喜欢一个人是什么感觉| 南冠指的是什么| 指鹿为马是什么生肖| 老鹰的天敌是什么| 迟缓是什么意思| 鬼畜什么意思| 下午6点是什么时辰| 墨西哥用什么货币| 羊肉放什么调料| 元宵节干什么| 慷慨什么| 犬瘟热是什么症状| abo什么意思| 大头虾是什么意思| 糖尿病人可以吃什么零食| 鸡蛋和面粉可以做什么好吃的| 脚底痛是什么原因| 来月经期间吃什么最好| 灼是什么意思| 上火了吃什么食物降火| 抗体和抗原有什么区别| 对食是什么意思| 什么荔枝最贵| 手痒是什么原因| 白粉虱用什么药| 看脑血管挂什么科| 潜规则是什么意思| 过期的酸奶有什么用途| 身上长湿疹是什么原因导致| Valentino什么牌子| 什么仗人势| 非主流什么意思| vj是什么意思| 牙齿经常出血是什么原因| 尿痛吃什么药效果最好| 喜悦之情溢于言表什么意思| 布病是什么| 教导是什么意思| 四级士官是什么级别| 手足口病咳嗽吃什么药| 微信屏蔽是什么意思| 身心俱疲是什么意思| 政协是干什么的| 牛气冲天是什么生肖| 指甲紫色是什么原因| 高反人群一般是什么人| 昏睡是什么症状| 感性是什么意思| 什么人容易得老年痴呆| 七字五行属什么| 梦见两个小男孩是什么意思| 男性生殖痒是什么原因| sjh是什么意思| 抑郁症吃什么药最好| 霉点用什么可以洗掉| 什么情况下做喉镜| 级配是什么意思| 痛经打什么针止痛| 手心脚心发热是什么原因引起的| 带黄金对身体有什么好处| 偏头疼是什么症状| 鼻咽癌有什么症状| 阑珊什么意思| 颈椎不舒服挂什么科| 柳丁是什么| 11号来月经什么时候是排卵期| 什么是平舌音什么是翘舌音| 苯是什么味道| 肚子经常胀气什么原因| 公历是什么意思| 双侧胸膜增厚是什么意思| 儿童铅超标有什么症状| 星字属于五行属什么| 胰腺检查挂什么科| 小孩子坐飞机需要什么证件| 夜未央是什么意思| 大便检查能查出什么病| 香港为什么叫香港| 儿女情长英雄气短是什么意思| 口苦口臭挂什么科| 扁桃体发炎吃什么药效果最好| 原发性和继发性是什么意思| 补气血喝什么| 征求是什么意思| 农历2月份是什么星座| 善存片什么时候吃最好| 腹泻吃什么好| peek是什么材料| 女人大把掉头发是什么原因| 甲子年是什么意思| 糖稀是什么| 日落是什么时辰| ns是什么| 6月22日什么星座| 问羊知马是什么生肖| 湿疹和热疹有什么区别| 和珅是什么官| 打包是什么意思| 眼袋浮肿是什么原因| 寿元是什么意思| 土人参长什么样| 减肥期间吃什么| 肺不好有什么症状| 什么水果低糖| 前列腺炎是什么原因引起的| nad是什么| 暴饮暴食会得什么病| 头发黄是什么原因| 铁树开花是什么意思| 扣字是什么意思| 凌志和雷克萨斯有什么区别| 梦见鳝鱼是什么预兆| 熟地黄有什么功效| 偏头痛有什么症状| 刹那芳华是什么意思| few是什么意思| 欧芹在中国叫什么| galaxy是什么牌子| 脚趾抽筋是什么原因| 乐的五行属性是什么| 棕色皮鞋配什么颜色裤子| 处暑的含义是什么意思| 跳脱是什么意思| 螃蟹吐泡泡是什么原因| 什么叫阴虚什么叫阳虚| 贸易壁垒是什么意思| 尿蛋白定量是什么意思| mmp是什么意思| 刚愎自用是什么生肖| 原浆酒是什么意思| c7是什么意思| 什么叫青光眼| cpap是什么意思| 什么花最大| 形单影只什么意思| 真如是什么意思| 亚麻籽油有什么功效| 双侧腋下见淋巴结什么意思| 动脉夹层什么意思| 蛮什么意思| 一厢情愿什么意思| 要强是什么意思| 今年为什么有两个6月| 5月11号是什么星座| 含金量什么意思| 药流后吃什么消炎药比较好| 喉咙痛吃什么药好| 心累是什么意思| 艳阳高照是什么生肖| 介入超声是什么意思| 现在执行死刑用什么方法| 遗传物质的载体是什么| 春分是什么意思| 吃什么补血快效果好| 今年为什么闰六月| 百忙之中什么意思| 乾隆的名字叫什么| 维生素c是补什么的| 肚子绞痛吃什么药| 土霉素喂鸡有什么作用| 百度Направо към съдържанието

от Уикипедия, свободната енциклопедия
百度 重点关注个股:汤森路透旗下的IFR周五援引消息人士的话称,中国电商巨头阿里巴巴最快将于今年年中在中国证券市场通过发行中国存托凭证(CDR)上市。


Чрез този модул се реализира функционалността на Шаблон:Infobox и Шаблон:Infobox3cols. За основа са ползвани версиите от английската уикипедия на модулите Infobox и Infobox3cols.


local p = {}
local args = {}
local origArgs
local root
local colspan = 2
local cat = { present = {}, ins = {} }

local function formatInput(str)
	-- Remove categories from data cells
	-- Add them in a separate table to be concatenated outside of the infobox
	str = mw.ustring.gsub(str, '(%[%[([^%[%]]-):[^%[%]]+%]%])', function (m, subm)
		subm = mw.text.trim(mw.ustring.lower(subm))
		if subm == 'категория' or subm == 'category' then
			if not cat.present[m] then
				cat.present[m] = true
				table.insert(cat.ins, m)
			end
			return ''
		end
		return m
	end)
	-- Remove an empty table or subbox
	str = mw.ustring.gsub(str, '<[Tt][Aa][Bb][Ll][Ee][^<>]*>%s*</[Tt][Aa][Bb][Ll][Ee]%s*>', '')

	if mw.ustring.match(str, '^%s*$') then
		-- Input is empty or contains only whitespace characters;
		-- no point to continue, so return nothing
		return nil
	end

	-- Add newline when a string begins and ends with
	-- wikilists
	str = mw.ustring.gsub(str, '^%s*([*#;:])', '\n%1')
	str = mw.ustring.gsub(str, '(\n[*#;:][^\n]*)%s*$', '%1\n')
	-- wikitables
	str = mw.ustring.gsub(str, '^%s*({|)', '\n%1')
	str = mw.ustring.gsub(str, '(\n|})%s*$', '%1\n')
	-- wikihorizontal rules
	str = mw.ustring.gsub(str, '^%s*(%-%-%-%-+)', '\n%1')
	str = mw.ustring.gsub(str, '(\n%-%-%-%-+)%s*$', '%1\n')

	return str
end

local function cleanInfobox(str)
	local last
	repeat
		last = str
		-- Remove empty row with other nested rows in it
		-- This occurs when an infobox with 'child' parameter is placed
		-- immediately inside a data, label or header cell
		-- and no other content precedes it/follows it
		str = mw.ustring.gsub(str, '<[Tt][Rr][^<>]*>%s*<[Tt][DdHh][^<>]*>%s*(<[Tt][Rr][^<>]*>%s*<[Tt][DdHh][^<>]*>)', '%1')
		str = mw.ustring.gsub(str, '(</[Tt][DdHh]%s*>%s*</[Tt][Rr]%s*>)%s*</[Tt][DdHh]%s*>%s*</[Tt][Rr]%s*>', '%1')
	until last == str
	return str
end

local function noMobileHRRow(str)
	-- Add class 'nomobile' when a row contains only horizontal rule
	if mw.ustring.match(str or '', '^%s*%-%-%-%-+%s*$') or mw.ustring.match(str or '', '^%s*<[Hh][Rr][^<>]*>%s*$') then
		return 'nomobile'
	end
	return nil
end

local function addSubboxClass(str)
	-- Add class 'has-subbox' when string
	if mw.ustring.match(str or '', '^%s*<[Tt][Aa][Bb][Ll][Ee][^<>]-["%s]infobox%-subbox["%s][^<>]*>.*</[Tt][Aa][Bb][Ll][Ee]%s*>%s*$') then
		return 'onlysubbox'
	end
	return nil
end

local function union(t1, t2)
	-- Returns the union of the values of two tables, as a sequence.
	local vals = {}
	for k, v in pairs(t1) do
		vals[v] = true
	end
	for k, v in pairs(t2) do
		vals[v] = true
	end
	local ret = {}
	for k, v in pairs(vals) do
		table.insert(ret, k)
	end
	return ret
end

local function getArgNums(prefix, suffix)
	-- Returns a table containing the numbers of the arguments that exist
	-- for the specified prefix. For example, if the prefix was 'data', and
	-- 'data1', 'data2', and 'data5' exist, it would return {1, 2, 5}.
	local nums = {}
	for k, v in pairs(args) do
		local num = tostring(k):match('^' .. prefix .. '([1-9]%d*)' .. (suffix or '') .. '$')
		if num then table.insert(nums, tonumber(num)) end
	end
	table.sort(nums)
	return nums
end

local function renderTitle()
	if not args.title then return end

	root:tag('caption')
		:addClass('infobox-title')
		:addClass(addSubboxClass(args.title))
		:addClass(args.titleclass)
		:cssText(args.titlestyle)
		:wikitext(args.title)
		:done()
end

local function renderAboveRow()
	if not args.above then return end

	root:tag('tr')
		:tag('td')
			:attr('colspan', colspan)
			:addClass('infobox-above')
			:addClass(addSubboxClass(args.above))
			:addClass(args.aboveclass)
			:cssText(args.abovestyle)
			:wikitext(args.above)
			:done()
end

local function addSubheaderRow(subheaderArgs)
	if not subheaderArgs.data then return end

	root:tag('tr')
		:addClass(subheaderArgs.rowclass)
		:tag('td')
			:attr('colspan', colspan)
			:addClass('infobox-subheader')
			:addClass(addSubboxClass(subheaderArgs.data))
			:addClass(subheaderArgs.class)
			:cssText(subheaderArgs.datastyle)
			:cssText(subheaderArgs.datastylenum)
			:wikitext(subheaderArgs.data)
			:done()
end

local function renderSubheaders()
	if args.subheader and not args.subheader1 then
		args.subheader1 = args.subheader
		args.subheaderrowclass1 = args.subheaderrowclass
	end
	local subheadernums = getArgNums('subheader')
	for k, num in ipairs(subheadernums) do
		addSubheaderRow({
			rowclass = args['subheaderrowclass' .. num],
			data = args['subheader' .. num],
			datastyle = args.subheaderstyle,
			datastylenum = args['subheaderstyle' .. num],
			class = args.subheaderclass,
		})
	end
end

local function addImageRow(imageArgs)
	if not imageArgs.data then return end

	root:tag('tr')
		:addClass(imageArgs.rowclass)
		:tag('td')
			:attr('colspan', colspan)
			:addClass('infobox-image')
			:addClass(addSubboxClass(imageArgs.data))
			:addClass(imageArgs.class)
			:cssText(imageArgs.datastyle)
			:cssText(imageArgs.datastylenum)
			:wikitext(imageArgs.data)
			:done()
end

local function renderImages()
	if args.image and not args.image1 then
		args.image1 = args.image
	end
	if args.caption and not args.caption1 then
		args.caption1 = args.caption
	end
	local imagenums = getArgNums('image')
	for k, num in ipairs(imagenums) do
		local caption = args['caption' .. num]
		local data = mw.html.create():wikitext(args['image' .. num])
		if caption then
			data:tag('div')
				:cssText(args.captionstyle)
				:wikitext(caption)
				:done()
		end
		addImageRow({
			rowclass = args['imagerowclass' .. num],
			data = tostring(data),
			datastyle = args.imagestyle,
			datastylenum = args['imagestyle' .. num],
			class = args.imageclass,
		})
	end
end

local function preprocessRows()
	if not args.autoheaders then return end

	local rownums = union(getArgNums('header'), getArgNums('data', '[abc]?'))
	table.sort(rownums)
	local lastheader
	for k, num in ipairs(rownums) do
		if args['header' .. num] then
			if lastheader then
				args['header' .. lastheader] = nil
			end
			lastheader = num
		elseif args['data' .. num] or args['data' .. num .. 'a'] or args['data' .. num .. 'b'] or args['data' .. num .. 'c'] then
			lastheader = nil
		end
	end
	if lastheader then
		args['header' .. lastheader] = nil
	end
end

local function addRow(rowArgs)
	-- Adds a row to the infobox, with either a header cell
	-- or a label/data cell combination.
	if rowArgs.header
	and mw.ustring.lower(rowArgs.header) ~= '_blank_'
	and mw.ustring.lower(rowArgs.header) ~= '_empty_'
	and mw.ustring.lower(rowArgs.header) ~= '_none_' then
		root:tag('tr')
			:addClass(noMobileHRRow(rowArgs.header))
			:addClass(rowArgs.rowclass)
			:cssText(rowArgs.rowstyle)
			:tag('th')
				:attr('colspan', colspan)
				:attr('scope', 'colgroup')
				:addClass('infobox-header')
				:addClass(addSubboxClass(rowArgs.header))
				:addClass(rowArgs.class)
				:addClass(args.headerclass)
				:cssText(args.headerstyle)
				:cssText(rowArgs.headerstyle)
				:wikitext(rowArgs.header)
				:done()
	elseif rowArgs.data then
		local row = root:tag('tr')
		if not rowArgs.label or noMobileHRRow(rowArgs.label) then
			row:addClass(noMobileHRRow(rowArgs.data))
		end
		row:addClass(rowArgs.rowclass)
		row:cssText(rowArgs.rowstyle)
		local span = colspan
		if rowArgs.label then
			span = span - 1
			row:tag('th')
				:attr('scope', 'row')
				:addClass('infobox-label')
				:addClass(addSubboxClass(rowArgs.label))
				:cssText(args.labelstyle)
				:cssText(rowArgs.labelstyle)
				:wikitext(rowArgs.label)
				:done()
		end
		row:tag('td')
			:attr('colspan', span > 1 and span or nil)
			:addClass(rowArgs.label and 'infobox-data' or 'infobox-data-only')
			:addClass(addSubboxClass(rowArgs.data))
			:addClass(rowArgs.class)
			:cssText(rowArgs.datastyle)
			:cssText(rowArgs.datastylenum)
			:wikitext(rowArgs.data)
			:done()
	elseif rowArgs.data_a then
		local row = root:tag('tr')
		row:addClass(rowArgs.rowclass)
		row:cssText(rowArgs.rowstyle)
		row:tag('th')
			:attr('scope', 'row')
			:addClass('infobox-label')
			:addClass(addSubboxClass(rowArgs.label))
			:cssText(args.labelstyle)
			:cssText(rowArgs.labelstyle)
			:wikitext(rowArgs.label)
			:done()
		row:tag('td')
				:addClass('infobox-data')
				:addClass(addSubboxClass(rowArgs.data_a))
				:addClass(rowArgs.class_a)
				:cssText(rowArgs.datastyle_a or rowArgs.datastyle)
				:cssText(rowArgs.datastylenum_a)
				:wikitext(rowArgs.data_a)
				:done()
		if args.render_b then
			row:tag('td')
				:addClass('infobox-data')
				:addClass(addSubboxClass(rowArgs.data_b))
				:addClass(rowArgs.class_b)
				:cssText(rowArgs.datastyle_b or rowArgs.datastyle)
				:cssText(rowArgs.datastylenum_b)
				:wikitext(rowArgs.data_b)
				:done()
		end
		if args.render_c then
			row:tag('td')
				:addClass('infobox-data')
				:addClass(addSubboxClass(rowArgs.data_c))
				:addClass(rowArgs.class_c)
				:cssText(rowArgs.datastyle_c or rowArgs.datastyle)
				:cssText(rowArgs.datastylenum_c)
				:wikitext(rowArgs.data_c)
				:done()
		end
	end
end

local function renderRows()
	-- Gets the union of the header and data argument numbers,
	-- and renders them all in order using addRow.
	local rownums = union(getArgNums('header'), getArgNums('data', '[abc]?'))
	table.sort(rownums)
	local title = mw.title.getCurrentTitle()
	for k, num in ipairs(rownums) do
		if title.namespace == 10 and args['header' .. num] and (args['data' .. num] or args['data' .. num .. 'a'] or args['data' .. num .. 'b'] or args['data' .. num .. 'c']) then
			mw.addWarning("<span style='color:red'>Едновременна употреба на ''header'' и ''data'' с числова наставка '''" .. num .. "'''.</span>")
		end
		addRow({
			rowclass = args['rowclass' .. num],
			rowstyle = args['rowstyle' .. num],
			header = args['header' .. num],
			headerstyle = args['headerstyle' .. num],
			label = args['label' .. num],
			labelstyle = args['labelstyle' .. num],
			data = args['data' .. num],
			datastyle = args.datastyle,
			datastylenum = args['datastyle' .. num],
			class = args['class' .. num],
			data_a = args['data' .. num .. 'a'],
			datastyle_a = args.datastylea,
			datastylenum_a = args['datastyle' .. num .. 'a'] or args['datastyle' .. num],
			class_a = args['class' .. num .. 'a'],
			data_b = args['data' .. num .. 'b'],
			datastyle_b = args.datastyleb,
			datastylenum_b = args['datastyle' .. num .. 'b'] or args['datastyle' .. num],
			class_b = args['class' .. num .. 'b'],
			data_c = args['data' .. num .. 'c'],
			datastyle_c = args.datastylec,
			datastylenum_c = args['datastyle' .. num .. 'c'] or args['datastyle' .. num],
			class_c = args['class' .. num .. 'c']
		})
	end
end

local function commonsBelow()
	local commons
	local entity = mw.wikibase.getEntity()
	local success, val = pcall(function() return entity['claims']['P373'][1]['mainsnak']['datavalue']['value'] end) -- Commons category property value

	if success then
		commons = 'Category:' .. val
	else
		success, val = pcall(function() return entity['claims']['P935'][1]['mainsnak']['datavalue']['value'] end) -- Commons gallery property value
		if success then
			commons = val
		else
			success, val = pcall(function() return entity['sitelinks']['commonswiki']['title'] end) -- Commons link value from multilanguage sites links menu
			if success then commons = val end
		end
	end

	if commons then
		return '<b class="plainlinks">[' .. tostring(mw.uri.fullUrl(':c:' .. commons, 'uselang=bg')) .. ' ' .. mw.ustring.gsub(mw.title.getCurrentTitle().text, '%s+%b()$', '') .. ']</b> в [[Общомедия]]'
	end

	return nil
end

local function renderBelowRow()
	if not (args.child or args.subbox) then
		if not args.below and not args.belowstyle then
			args.belowstyle = args.headerstyle or args.abovestyle
		end
		args.below = args.below or commonsBelow() -- Get commons only when an infobox doesn't have subbox/child params
	end
	if not args.below then return end

	root:tag('tr')
		:tag('td')
			:attr('colspan', colspan)
			:addClass('infobox-below')
			:addClass(addSubboxClass(args.below))
			:addClass(args.belowclass)
			:cssText(args.belowstyle)
			:wikitext(args.below)
			:done()
end

local function renderNavBar()
	if not args.name then return end

	root:tag('tr')
		:tag('td')
			:attr('colspan', colspan)
			:addClass('infobox-navbar')
			:wikitext(mw.getCurrentFrame():expandTemplate{ title = 'navbar', args = {args.name, mini = 1}})
			:done()
end

local function renderItalicTitle()
	if args.child == 'yes' or args.subbox == 'yes' then return end

	local italicTitle = args['italic title'] and mw.ustring.lower(args['italic title'])
	if italicTitle == '' or italicTitle == 'force' or italicTitle == 'yes' then
		root:tag('tr')
			:addClass('infobox-italic-title')
			:tag('td')
				:attr('colspan', colspan)
				:wikitext(mw.getCurrentFrame():expandTemplate{title = 'italic title'})
				:done()
	end
end

local function loadTemplateStyles()
	if args.child == 'yes' or args.subbox == 'yes' then return '' end

	return mw.getCurrentFrame():extensionTag{
		name = 'templatestyles',
		args = { src = 'Модул:Infobox/styles.css' }
	}
end

local function _infobox()
	-- Specify the overall layout of the infobox, with special settings
	-- if the infobox is used as a 'child' inside another infobox.'
	if args.child ~= 'yes' then
		root = mw.html.create('table')
		root:addClass('infobox')
		if args.subbox == 'yes' then
			root:addClass('infobox-subbox')
		else
			root:addClass('infobox-lua')
		end
		root:addClass(args.bodyclass)
		root:cssText(args.bodystyle)
		renderTitle()
		renderAboveRow()
	else
		root = mw.html.create()
		root:wikitext(args.title)
	end

	renderSubheaders()
	renderImages()
	preprocessRows()
	renderRows()
	renderBelowRow()
	renderNavBar()
	renderItalicTitle()

	return loadTemplateStyles() .. cleanInfobox(tostring(root)) .. table.concat(cat.ins)
end

local function preprocessSingleArg(argName, prefix)
	-- If the argument exists and isn't blank, add it to the argument table.
	-- Blank arguments are treated as nil to match the behaviour of ParserFunctions.
	if origArgs[argName] and origArgs[argName] ~= '' then
		prefix = prefix or argName
		if prefix == 'title' or prefix == 'above' or prefix == 'subheader'
		or prefix == 'image' or prefix == 'caption' or prefix == 'header'
		or prefix == 'label' or prefix == 'data' or prefix == 'below' then
			args[argName] = formatInput(origArgs[argName])
		else
			args[argName] = origArgs[argName]
		end
	end
end

local function preprocessArgs(prefixTable, step)
	-- Assign the parameters with the given prefixes to the args table, in order, in batches
	-- of the step size specified. This is to prevent references etc. from appearing in the
	-- wrong order. The prefixTable should be an array containing tables, each of which has
	-- two possible fields, a "prefix" string and a "depend" table. The function always parses
	-- parameters containing the "prefix" string, but only parses parameters in the "depend"
	-- table if the prefix parameter is present and non-blank.
	if type(prefixTable) ~= 'table' then
		error("Non-table value detected for the prefix table", 2)
	end
	if type(step) ~= 'number' then
		error("Invalid step value detected", 2)
	end

	-- Get arguments without a number suffix, and check for bad input.
	for i, v in ipairs(prefixTable) do
		if type(v) ~= 'table' or type(v.prefix) ~= "string" or (v.depend and type(v.depend) ~= 'table') or (v.suffix and type(v.suffix) ~= 'table') then
			error('Invalid input detected to preprocessArgs prefix table', 2)
		end
		preprocessSingleArg(v.prefix)
		-- Only parse the depend parameter if the prefix parameter is present and not blank.
		if args[v.prefix] and v.depend then
			for j, dependValue in ipairs(v.depend) do
				if type(dependValue) ~= 'string' then
					error('Invalid "depend" parameter value detected in preprocessArgs')
				end
				preprocessSingleArg(dependValue)
			end
		end
	end

	-- Get arguments with number suffixes.
	local moreArgumentsExist
	local a = 1 -- Counter variable.
	repeat
		moreArgumentsExist = false
		for i = a, a + step - 1 do
			for j, v in ipairs(prefixTable) do
				v.suffix = v.suffix or {''}
				for k = 1, #v.suffix do
					local prefixArgName = v.prefix .. i .. v.suffix[k]
					if origArgs[prefixArgName] then
						moreArgumentsExist = true -- Do another loop if any arguments are found, even blank ones.
						preprocessSingleArg(prefixArgName, v.prefix)
						if v.prefix == 'data' and args[prefixArgName] then
							if not args.render_b and v.suffix[k] == 'b' then
								args.render_b = true
							elseif not args.render_c and v.suffix[k] == 'c' then
								args.render_c = true
							end
						end
					end
					-- Process the depend table if the prefix argument is present and not blank, or
					-- we are processing "prefix1" and "prefix" is present and not blank, and
					-- if the depend table is present.
					if v.depend and (args[prefixArgName] or (i == 1 and args[v.prefix])) then
						for l, dependValue in ipairs(v.depend) do
							local dependArgName = dependValue .. i .. v.suffix[k]
							preprocessSingleArg(dependArgName, dependValue)
						end
					end
				end
			end
		end
		a = a + step
	until not moreArgumentsExist
end

local function parseArgs(frame, version)
	-- If called via #invoke, use the args passed into the invoking template.
	-- Otherwise, for testing purposes, assume args are being passed directly in.
	if frame == mw.getCurrentFrame() then
		origArgs = frame:getParent().args
	else
		origArgs = frame
	end

	-- Parse the data parameters in the same order that the old {{infobox}} did, so that
	-- references etc. will display in the expected places. Parameters that depend on
	-- another parameter are only processed if that parameter is present, to avoid
	-- phantom references appearing in article reference lists.
	args['child'] = origArgs['child'] -- could be blank or absent; different behaviour because of renderBelowRow()
	args['subbox'] = origArgs['subbox'] -- could be blank or absent; different behaviour because of renderBelowRow()
	args['italic title'] = origArgs['italic title'] -- different behaviour if blank or absent
	preprocessSingleArg('autoheaders')
	preprocessSingleArg('bodyclass')
	preprocessSingleArg('bodystyle')
	preprocessSingleArg('title')
	preprocessSingleArg('titleclass')
	preprocessSingleArg('titlestyle')
	preprocessSingleArg('above')
	preprocessSingleArg('aboveclass')
	preprocessSingleArg('abovestyle')
	preprocessArgs({
		{prefix = 'subheader', depend = {'subheaderstyle', 'subheaderrowclass'}}
	}, 10)
	preprocessSingleArg('subheaderstyle')
	preprocessSingleArg('subheaderclass')
	preprocessSingleArg('image')
	preprocessSingleArg('caption')
	preprocessArgs({
		{prefix = 'image', depend = {'caption', 'imagestyle', 'imagerowclass'}}
	}, 10)
	preprocessSingleArg('captionstyle')
	preprocessSingleArg('imagestyle')
	preprocessSingleArg('imageclass')
	if version == 'infobox' then
		preprocessArgs({
			{prefix = 'header', depend = {'headerstyle'}},
			{prefix = 'label', depend = {'labelstyle'}},
			{prefix = 'data', depend = {'datastyle', 'class'}},
			{prefix = 'rowclass'},
			{prefix = 'rowstyle'}
		}, 50)
	elseif version == 'infobox3cols' then
		preprocessArgs({
			{prefix = 'header', depend = {'headerstyle'}},
			{prefix = 'label', depend = {'labelstyle'}},
			{prefix = 'data', depend = {'datastyle', 'class'}, suffix = {'', 'a', 'b', 'c'}},
			{prefix = 'rowclass'},
			{prefix = 'rowstyle'},
		}, 50)
	end
	preprocessSingleArg('headerclass')
	preprocessSingleArg('headerstyle')
	preprocessSingleArg('labelstyle')
	preprocessSingleArg('datastyle')
	if version == 'infobox3cols' then
		preprocessSingleArg('datastylea')
		preprocessSingleArg('datastyleb')
		preprocessSingleArg('datastylec')
	end
	preprocessSingleArg('below')
	preprocessSingleArg('belowclass')
	preprocessSingleArg('belowstyle')
	preprocessSingleArg('name')
end

function p.infobox(frame)
	parseArgs(frame, 'infobox')
	return _infobox()
end

function p.infobox3cols(frame)
	parseArgs(frame, 'infobox3cols')
	if args.child == 'yes' then
		args.subbox = 'yes'
		args.child = nil
	end
	colspan = colspan + (args.render_b and 1 or 0) + (args.render_c and 1 or 0)
	return _infobox()
end

return p
什么是水痘 癌胚抗原偏高说明什么 腿凉是什么原因引起的 球是什么生肖 晕车吃什么
尿胆原阳性是什么病 butter是什么意思 公立医院和私立医院有什么区别 汤姆猫是什么品种 什么蘑菇
男人为什么喜欢舔女人下面 什么是公元前和公元后 吃什么能去黑眼圈 蒲公英泡水喝有什么功效 形态是什么意思
什么叫静脉曲张 逃之夭夭是什么意思 梦见小男孩是什么预兆 骨蒸潮热是什么意思 看见蛇有什么预兆
口水多是什么原因引起的beikeqingting.com 查血压高挂什么科室hcv9jop2ns6r.cn 猹是什么hcv9jop2ns1r.cn 高级护理是干什么的hcv9jop2ns9r.cn 深圳少年宫有什么好玩的hcv9jop4ns1r.cn
湿吻是什么意思hcv8jop5ns5r.cn 生殖器疱疹是什么原因引起的hcv7jop6ns4r.cn 乌鸡放什么炖补气补血hcv8jop5ns3r.cn 特应性皮炎用什么药膏hcv8jop4ns7r.cn 减张缝合是什么意思hcv9jop1ns1r.cn
尿路感染喝什么药hcv7jop6ns0r.cn 儿童支原体感染吃什么药wuhaiwuya.com 咳嗽有黄痰吃什么药hcv8jop7ns7r.cn 脸颊为什么会凹陷hcv9jop2ns7r.cn 普瑞巴林是什么药hcv9jop6ns5r.cn
mlf是什么意思hcv9jop6ns2r.cn 白色的鱼是什么鱼hcv8jop1ns1r.cn 献血有什么要求hcv8jop9ns7r.cn 做梦梦见屎是什么意思hcv8jop1ns9r.cn fan什么意思hcv9jop0ns2r.cn
百度