叫人挪车打什么电话| 堂哥的女儿叫什么| 肝火旺盛吃什么| 动情是什么意思| 脂肪肝吃什么中药| 肉字五行属什么| 单人旁的字有什么| 痛风吃什么食物好得快| 熊猫为什么吃竹子| 什么是匝道| 零零年属什么| 花生属于什么类| 本能反应是什么意思| 电动车电池什么牌子好| 洋葱与什么食物相克| 痛风可以吃什么鱼| 睡觉起来脸肿是什么原因引起的| 胃糜烂吃什么药| 金酒属于什么酒| 岁次什么意思| ptc是什么| 孕妇能喝什么饮料| 黑油是什么油| 腋下有疙瘩是什么原因| 脚底疼痛是什么原因| 母女丼什么意思| 都有什么花| 车挂件挂什么保平安好| 6月8号什么星座| 做水果捞用什么酸奶好| 天秤女喜欢什么样的男生| 梦到前夫什么意思| 细菌性毛囊炎用什么药| 迎字五行属什么| 黄芪是什么样子的| 手脚发热是什么原因| 邪不压正什么意思| 北海有什么好玩的| bally什么档次| 胰腺炎为什么血糖高| 精神衰弱吃什么能改善| 归脾丸和健脾丸有什么区别| 阴道有腥味是什么原因| 韩红是什么军衔| 家伙是什么意思| 什么的羊圈| 花匠是什么意思| 秦始皇是芈月的什么人| 血管堵塞吃什么好| 月经提前十天是什么原因| 腰酸背痛吃什么药| 乳腺彩超什么时候做最准确| 螨虫怕什么| 春天什么花开| 回族人为什么不吃猪肉| epd是什么意思| 晴雨伞是什么意思| 内脂豆腐是什么| 东海龙王叫什么名字| 梦见雨伞是什么意思| 飞机联程票是什么意思| 膝盖擦伤用什么药| 羟丁酸脱氢酶高是什么原因| 恶心是什么意思| 余事勿取什么意思| 大肠头是什么部位| ug是什么意思| 胃胀打嗝吃什么药最好| 看演唱会需要准备什么| 神经衰弱吃什么中成药| 吃什么可以长胖| 红曲红是什么东西| 哪吒代表什么生肖| 波司登是什么档次| 学无止境是什么意思| 布洛芬有什么副作用| 头发里长痣代表什么| 最里面的牙齿叫什么牙| chick是什么意思| 恐龙生活在什么时代| 牙周炎用什么药最好| 木丹念什么| 文曲星是什么神仙| 10.19什么星座| mom什么意思| 柿子叶有什么功效| 糖尿病人吃什么水果| 甲醛闻多了有什么症状| 孕妇奶粉什么时候开始喝最好| 什么胆忠心| 喝酒前吃什么不容易醉| 天上的星星像什么| 蛔虫和蛲虫有什么区别| 毳毛是什么| 甲钴胺片主治什么病| 固液法白酒是什么意思| 9月27是什么星座| 检查心脏做什么检查| 烧心是什么原因引起的| 检点是什么意思| 突然晕倒是什么原因造成的| 为什么拉黑色的屎| 对视是什么意思| 丁丁历险记的狗是什么品种| 天团是什么意思| 什么食物吃了会胀气| 牙疼吃什么食物好得快| 为什么不建议光子嫩肤| 花仙子是什么意思| 瘦肚子吃什么水果| 11月份生日是什么星座| 吃什么能让月经量增多| 脸肿挂什么科| 沙土地适合种什么农作物| 吃什么雌激素会增多| 与时俱进是什么意思| 为什么会长脂肪粒| 拉肚子适合吃什么| 梦到僵尸是什么预兆| 什么是中出| 领衔是什么意思| 哺乳期是什么意思| 查黄体酮做什么检查| 渗透压是什么| 清白是什么意思| 左手虎口有痣代表什么| 转氨酶高挂什么科| 宝宝大便发白是什么原因| 油嘴滑舌是什么意思| 超声科检查什么| 嘴角长水泡是什么原因| 人得布病什么症状| 澳门是什么时候回归的| 尿道痒痒是什么原因| 抱窝是什么意思| 天真是什么意思| 98年的属什么| 中级会计什么时候报名| 排骨炖山药有什么功效| 莆田系是什么意思啊| 急性肠胃炎吃什么药效果好| 月经期间能吃什么水果| 鼻咽炎有什么症状| 身份证末尾x代表什么| 12月有什么节日| 女人右手断掌代表什么| 异常子宫出血是什么原因| 师五行属什么| pro是什么意思| 早搏有什么症状| 孕期便秘吃什么通便快| 直率是什么意思| 女生怀孕的前兆是什么| 眼镜发明之前眼镜蛇叫什么| 人怕出名猪怕壮是什么生肖| 林俊杰的粉丝叫什么| 周杰伦是什么星座| 腹黑什么意思| 查贫血挂什么科| 宫缩疼是什么感觉| 重阳节又称什么节| 老是低血糖是什么原因| 男人为什么喜欢吸奶| 什么是作风建设| 沼泽地是什么意思| 临床诊断是什么意思| 感性是什么意思| 女人脚底有痣代表什么| 梦见蜘蛛网是什么意思| 电销是什么工作| 00年属龙的是什么命| 张字五行属什么| 总是失眠是什么原因| 为什么会长子宫肌瘤| 做梦抓鱼什么意思周公解梦| 什么是简历| 阑尾炎是什么症状| 炸东西用什么淀粉| 脑电图是检查什么的| 女生读什么技校好| 懿是什么意思| 头发为什么会掉| 胃挂什么科| 什么时间泡脚最好| 早泄是什么原因导致| 2是什么意思| 得令是什么意思| cip是什么| 一个白一个本是什么字| 男人做什么运动能提高性功能| 检查肠道挂什么科| 女性私处长痘痘是什么原因| 新疆是什么地貌| 257什么意思| 什么旺水命| lt是什么意思| 神经痛用什么药| 什么是耽美| 什么是生物工程| 2015年属什么生肖| 肛裂出血和痔疮出血有什么区别| 酒不能和什么一起吃| 打了封闭针后要注意什么事项| 早晨4点是什么时辰| 儿童鼻炎吃什么药| 早上9点到10点是什么时辰| 言谈举止是什么意思| hcg什么时候开始下降| 徐峥的老婆叫什么名字| 自由基是什么| 香港特首是什么级别| 深蹲有什么好处| 腱鞘炎去医院挂什么科| 大三阳转小三阳意味着什么| 肠上皮化生是什么意思| 颈椎退变是什么意思| 甲氨蝶呤是什么药| 天庭是什么意思| 磁共振是查什么的| 火烧云是什么意思| 婴儿吃手是什么原因| 菊花可以和什么一起泡水喝| 什么叫血压| 属猴的本命佛是什么佛| 粘膜慢性炎是什么病| 牛肉和什么菜包饺子好吃| 主动脉硬化什么意思| 甲亢吃什么盐| 肌瘤是什么| 栀子泡水喝有什么好处| utc是什么意思| 痔疮发痒是什么原因| 凌迟是什么| 月经期吃什么| 浩特是什么意思| 肠梗阻挂什么科| 7月24日是什么日子| 锦囊妙计是什么意思| 咳嗽发烧是什么原因| 失眠挂什么科| 什么的去路| 血压为什么晚上高| 肩周炎属于什么科室| 喝什么茶降血压最好最快| 有时候会感到莫名的难过是什么歌| 什么可以代替人体润滑油| 头晕是什么病的前兆| 孕吐喝什么水可以缓解| 宫颈口出血是什么原因| 砂仁是什么| 睡觉经常做梦是什么原因| 舌头疼吃什么药好得快| 柳字五行属什么| 尿酸高去医院挂什么科| 四个雷念什么| 口腔医学技术是干什么的| 梦到自己结婚什么意思| 什么叫天干| 咳白色泡沫痰吃什么药| tg什么意思| 自闭症是什么原因引起| 悦风空调是什么牌子| 食糜是什么意思| 蜈蚣是什么样的| 百度Jump to content

《东方红丛书》简介 十四、《红色风暴》(4)

Permanently protected module
From Wikipedia, the free encyclopedia

local p = {}
local args = {}
local origArgs = {}
local root
local empty_row_categories = {}
local category_in_empty_row_pattern = '%[%[%s*[Cc][Aa][Tt][Ee][Gg][Oo][Rr][Yy]%s*:[^]]*]]'
local has_rows = false
local lists = {
	plainlist_t = {
		patterns = {
			'^plainlist$',
			'%splainlist$',
			'^plainlist%s',
			'%splainlist%s'
		},
		found = false,
		styles = 'Plainlist/styles.css'
	},
	hlist_t = {
		patterns = {
			'^hlist$',
			'%shlist$',
			'^hlist%s',
			'%shlist%s'
		},
		found = false,
		styles = 'Hlist/styles.css'
	}
}

local function has_list_class(args_to_check)
	for _, list in pairs(lists) do
		if not list.found then
			for _, arg in pairs(args_to_check) do
				for _, pattern in ipairs(list.patterns) do
					if mw.ustring.find(arg or '', pattern) then
						list.found = true
						break
					end
				end
				if list.found then break end
			end
		end
	end
end

local function fixChildBoxes(sval, tt)
	local function notempty( s ) return s and s:match( '%S' ) end
	
	if notempty(sval) then
		local marker = '<span class=special_infobox_marker>'
		local s = sval
		-- start moving templatestyles and categories inside of table rows
		local slast = ''
		while slast ~= s do
			slast = s
			s = mw.ustring.gsub(s, '(</[Tt][Rr]%s*>%s*)(%[%[%s*[Cc][Aa][Tt][Ee][Gg][Oo][Rr][Yy]%s*:[^]]*%]%])', '%2%1')
			s = mw.ustring.gsub(s, '(</[Tt][Rr]%s*>%s*)(\127[^\127]*UNIQ%-%-templatestyles%-%x+%-QINU[^\127]*\127)', '%2%1')
		end
		-- end moving templatestyles and categories inside of table rows
		s = mw.ustring.gsub(s, '(<%s*[Tt][Rr])', marker .. '%1')
		s = mw.ustring.gsub(s, '(</[Tt][Rr]%s*>)', '%1' .. marker)
		if s:match(marker) then
			s = mw.ustring.gsub(s, marker .. '%s*' .. marker, '')
			s = mw.ustring.gsub(s, '([\r\n]|-[^\r\n]*[\r\n])%s*' .. marker, '%1')
			s = mw.ustring.gsub(s, marker .. '%s*([\r\n]|-)', '%1')
			s = mw.ustring.gsub(s, '(</[Cc][Aa][Pp][Tt][Ii][Oo][Nn]%s*>%s*)' .. marker, '%1')
			s = mw.ustring.gsub(s, '(<%s*[Tt][Aa][Bb][Ll][Ee][^<>]*>%s*)' .. marker, '%1')
			s = mw.ustring.gsub(s, '^(%{|[^\r\n]*[\r\n]%s*)' .. marker, '%1')
			s = mw.ustring.gsub(s, '([\r\n]%{|[^\r\n]*[\r\n]%s*)' .. marker, '%1')
			s = mw.ustring.gsub(s, marker .. '(%s*</[Tt][Aa][Bb][Ll][Ee]%s*>)', '%1')
			s = mw.ustring.gsub(s, marker .. '(%s*\n|%})', '%1')
		end
		if s:match(marker) then
			local subcells = mw.text.split(s, marker)
			s = ''
			for k = 1, #subcells do
				if k == 1 then
					s = s .. subcells[k] .. '</' .. tt .. '></tr>'
				elseif k == #subcells then
					local rowstyle = ' style="display:none"'
					if notempty(subcells[k]) then rowstyle = ''	end
					s = s .. '<tr' .. rowstyle ..'><' .. tt .. ' colspan=2>\n' ..
						subcells[k]
				elseif notempty(subcells[k]) then
					if (k % 2) == 0 then
						s = s .. subcells[k]
					else
						s = s .. '<tr><' .. tt .. ' colspan=2>\n' ..
							subcells[k] .. '</' .. tt .. '></tr>'
					end
				end
			end
		end
		-- the next two lines add a newline at the end of lists for the PHP parser
		-- [[Special:Diff/849054481]]
		-- remove when [[:phab:T191516]] is fixed or OBE
		s = mw.ustring.gsub(s, '([\r\n][%*#;:][^\r\n]*)$', '%1\n')
		s = mw.ustring.gsub(s, '^([%*#;:][^\r\n]*)$', '%1\n')
		s = mw.ustring.gsub(s, '^([%*#;:])', '\n%1')
		s = mw.ustring.gsub(s, '^(%{%|)', '\n%1')
		return s
	else
		return sval
	end
end

-- Cleans empty tables
local function cleanInfobox()
	root = tostring(root)
	if has_rows == false then
		root = mw.ustring.gsub(root, '<table[^<>]*>%s*</table>', '')
	end
end

-- Returns the union of the values of two tables, as a sequence.
local function union(t1, t2)

	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

-- 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 function getArgNums(prefix)
	local nums = {}
	for k, v in pairs(args) do
		local num = tostring(k):match('^' .. prefix .. '([1-9]%d*)$')
		if num then table.insert(nums, tonumber(num)) end
	end
	table.sort(nums)
	return nums
end

-- Adds a row to the infobox, with either a header cell
-- or a label/data cell combination.
local function addRow(rowArgs)
	
	if rowArgs.header and rowArgs.header ~= '_BLANK_' then
		has_rows = true
		has_list_class({ rowArgs.rowclass, rowArgs.class, args.headerclass })
		
		root
			:tag('tr')
				:addClass(rowArgs.rowclass)
				:cssText(rowArgs.rowstyle)
				:tag('th')
					:attr('colspan', '2')
					:addClass('infobox-header')
					:addClass(rowArgs.class)
					:addClass(args.headerclass)
					-- @deprecated next; target .infobox-<name> .infobox-header
					:cssText(args.headerstyle)
					:cssText(rowArgs.rowcellstyle)
					:wikitext(fixChildBoxes(rowArgs.header, 'th'))
		if rowArgs.data then
			root:wikitext(
				'[[Category:Pages using infobox templates with ignored data cells]]'
			)
		end
	elseif rowArgs.data and rowArgs.data:gsub(category_in_empty_row_pattern, ''):match('^%S') then
		has_rows = true
		has_list_class({ rowArgs.rowclass, rowArgs.class })
		
		local row = root:tag('tr')
		row:addClass(rowArgs.rowclass)
		row:cssText(rowArgs.rowstyle)
		if rowArgs.label then
			row
				:tag('th')
					:attr('scope', 'row')
					:addClass('infobox-label')
					-- @deprecated next; target .infobox-<name> .infobox-label
					:cssText(args.labelstyle)
					:cssText(rowArgs.rowcellstyle)
					:wikitext(rowArgs.label)
					:done()
		end

		local dataCell = row:tag('td')
		dataCell
			:attr('colspan', not rowArgs.label and '2' or nil)
			:addClass(not rowArgs.label and 'infobox-full-data' or 'infobox-data')
			:addClass(rowArgs.class)
			-- @deprecated next; target .infobox-<name> .infobox(-full)-data
			:cssText(rowArgs.datastyle)
			:cssText(rowArgs.rowcellstyle)
			:wikitext(fixChildBoxes(rowArgs.data, 'td'))
	else
		table.insert(empty_row_categories, rowArgs.data or '')
	end
end

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

	has_rows = true
	has_list_class({args.titleclass})
	
	root
		:tag('caption')
			:addClass('infobox-title')
			:addClass(args.titleclass)
			-- @deprecated next; target .infobox-<name> .infobox-title
			:cssText(args.titlestyle)
			:wikitext(args.title)
	
end

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

	has_rows = true
	has_list_class({ args.aboveclass })
	
	root
		:tag('tr')
			:tag('th')
				:attr('colspan', '2')
				:addClass('infobox-above')
				:addClass(args.aboveclass)
				-- @deprecated next; target .infobox-<name> .infobox-above
				:cssText(args.abovestyle)
				:wikitext(fixChildBoxes(args.above,'th'))
end

local function renderBelowRow()
	if not args.below then return end

	has_rows = true
	has_list_class({ args.belowclass })
	
	root
		:tag('tr')
			:tag('td')
				:attr('colspan', '2')
				:addClass('infobox-below')
				:addClass(args.belowclass)
				-- @deprecated next; target .infobox-<name> .infobox-below
				:cssText(args.belowstyle)
				:wikitext(fixChildBoxes(args.below,'td'))
end

local function addSubheaderRow(subheaderArgs)
	if subheaderArgs.data and
		subheaderArgs.data:gsub(category_in_empty_row_pattern, ''):match('^%S') then
		has_rows = true
		has_list_class({ subheaderArgs.rowclass, subheaderArgs.class })
		
		local row = root:tag('tr')
		row:addClass(subheaderArgs.rowclass)

		local dataCell = row:tag('td')
		dataCell
			:attr('colspan', '2')
			:addClass('infobox-subheader')
			:addClass(subheaderArgs.class)
			:cssText(subheaderArgs.datastyle)
			:cssText(subheaderArgs.rowcellstyle)
			:wikitext(fixChildBoxes(subheaderArgs.data, 'td'))
	else
		table.insert(empty_row_categories, subheaderArgs.data or '')
	end
end

local function renderSubheaders()
	if args.subheader then
		args.subheader1 = args.subheader
	end
	if args.subheaderrowclass then
		args.subheaderrowclass1 = args.subheaderrowclass
	end
	local subheadernums = getArgNums('subheader')
	for k, num in ipairs(subheadernums) do
		addSubheaderRow({
			data = args['subheader' .. tostring(num)],
			-- @deprecated next; target .infobox-<name> .infobox-subheader
			datastyle = args.subheaderstyle,
			rowcellstyle = args['subheaderstyle' .. tostring(num)],
			class = args.subheaderclass,
			rowclass = args['subheaderrowclass' .. tostring(num)]
		})
	end
end

local function addImageRow(imageArgs)

	if imageArgs.data and
		imageArgs.data:gsub(category_in_empty_row_pattern, ''):match('^%S') then

		has_rows = true
		has_list_class({ imageArgs.rowclass, imageArgs.class })
		
		local row = root:tag('tr')
		row:addClass(imageArgs.rowclass)

		local dataCell = row:tag('td')
		dataCell
			:attr('colspan', '2')
			:addClass('infobox-image')
			:addClass(imageArgs.class)
			:cssText(imageArgs.datastyle)
			:wikitext(fixChildBoxes(imageArgs.data, 'td'))
	else
		table.insert(empty_row_categories, imageArgs.data or '')
	end
end

local function renderImages()
	if args.image then
		args.image1 = args.image
	end
	if args.caption then
		args.caption1 = args.caption
	end
	local imagenums = getArgNums('image')
	for k, num in ipairs(imagenums) do
		local caption = args['caption' .. tostring(num)]
		local data = mw.html.create():wikitext(args['image' .. tostring(num)])
		if caption then
			data
				:tag('div')
					:addClass('infobox-caption')
					-- @deprecated next; target .infobox-<name> .infobox-caption
					:cssText(args.captionstyle)
					:wikitext(caption)
		end
		addImageRow({
			data = tostring(data),
			-- @deprecated next; target .infobox-<name> .infobox-image
			datastyle = args.imagestyle,
			class = args.imageclass,
			rowclass = args['imagerowclass' .. tostring(num)]
		})
	end
end

-- When autoheaders are turned on, preprocesses the rows
local function preprocessRows()
	if not args.autoheaders then return end
	
	local rownums = union(getArgNums('header'), getArgNums('data'))
	table.sort(rownums)
	local lastheader
	for k, num in ipairs(rownums) do
		if args['header' .. tostring(num)] then
			if lastheader then
				args['header' .. tostring(lastheader)] = nil
			end
			lastheader = num
		elseif args['data' .. tostring(num)] and
			args['data' .. tostring(num)]:gsub(
				category_in_empty_row_pattern, ''
			):match('^%S') then
			local data = args['data' .. tostring(num)]
			if data:gsub(category_in_empty_row_pattern, ''):match('%S') then
				lastheader = nil
			end
		end
	end
	if lastheader then
		args['header' .. tostring(lastheader)] = nil
	end
end

-- Gets the union of the header and data argument numbers,
-- and renders them all in order
local function renderRows()

	local rownums = union(getArgNums('header'), getArgNums('data'))
	table.sort(rownums)
	for k, num in ipairs(rownums) do
		addRow({
			header = args['header' .. tostring(num)],
			label = args['label' .. tostring(num)],
			data = args['data' .. tostring(num)],
			datastyle = args.datastyle,
			class = args['class' .. tostring(num)],
			rowclass = args['rowclass' .. tostring(num)],
			-- @deprecated next; target .infobox-<name> rowclass
			rowstyle = args['rowstyle' .. tostring(num)],
			rowcellstyle = args['rowcellstyle' .. tostring(num)]
		})
	end
end

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

	has_rows = true
	root
		:tag('tr')
			:tag('td')
				:attr('colspan', '2')
				:addClass('infobox-navbar')
				:wikitext(require('Module:Navbar')._navbar{
					args.name,
					mini = 1,
				})
end

local function renderItalicTitle()
	local italicTitle = args['italic title'] and mw.ustring.lower(args['italic title'])
	if italicTitle == '' or italicTitle == 'force' or italicTitle == 'yes' then
		root:wikitext(require('Module:Italic title')._main({}))
	end
end

-- Categories in otherwise empty rows are collected in empty_row_categories.
-- This function adds them to the module output. It is not affected by
-- args.decat because this module should not prevent module-external categories
-- from rendering.
local function renderEmptyRowCategories()
	for _, s in ipairs(empty_row_categories) do
		root:wikitext(s)
	end
end

-- Render tracking categories. args.decat == turns off tracking categories.
local function renderTrackingCategories()
	if args.decat == 'yes' then return end
	if args.child == 'yes' then
		if args.title then
			root:wikitext(
				'[[Category:Pages using embedded infobox templates with the title parameter]]'
			)
		end
	elseif #(getArgNums('data')) == 0 and mw.title.getCurrentTitle().namespace == 0 then
		root:wikitext('[[Category:Articles using infobox templates with no data rows]]')
	end
end

--[=[
Loads the templatestyles for the infobox.

TODO: FINISH loading base templatestyles here rather than in
MediaWiki:Common.css. There are 4-5000 pages with 'raw' infobox tables.
See [[Mediawiki_talk:Common.css/to_do#Infobox]] and/or come help :).
When we do this we should clean up the inline CSS below too.
Will have to do some bizarre conversion category like with sidebar.

]=]
local function loadTemplateStyles()
	local frame = mw.getCurrentFrame()
	
	local hlist_templatestyles = ''
	if lists.hlist_t.found then
		hlist_templatestyles = frame:extensionTag{
			name = 'templatestyles', args = { src = lists.hlist_t.styles }
		}
	end
	
	local plainlist_templatestyles = ''
	if lists.plainlist_t.found then
		plainlist_templatestyles = frame:extensionTag{
			name = 'templatestyles', args = { src = lists.plainlist_t.styles }
		}
	end
	
	-- See function description
	local base_templatestyles = frame:extensionTag{
		name = 'templatestyles', args = { src = 'Module:Infobox/styles.css' }
	}

	local templatestyles = ''
	if args['templatestyles'] then
		templatestyles = frame:extensionTag{
			name = 'templatestyles', args = { src = args['templatestyles'] }
		}
	end
	
	local child_templatestyles = ''
	if args['child templatestyles'] then
		child_templatestyles = frame:extensionTag{
			name = 'templatestyles', args = { src = args['child templatestyles'] }
		}
	end
	
	local grandchild_templatestyles = ''
	if args['grandchild templatestyles'] then
		grandchild_templatestyles = frame:extensionTag{
			name = 'templatestyles', args = { src = args['grandchild templatestyles'] }
		}
	end
	
	return table.concat({
		-- hlist -> plainlist -> base is best-effort to preserve old Common.css ordering.
		-- this ordering is not a guarantee because the rows of interest invoking
		-- each class may not be on a specific page
		hlist_templatestyles,
		plainlist_templatestyles,
		base_templatestyles,
		templatestyles,
		child_templatestyles,
		grandchild_templatestyles
	})
end

-- common functions between the child and non child cases
local function structure_infobox_common()
	renderSubheaders()
	renderImages()
	preprocessRows()
	renderRows()
	renderBelowRow()
	renderNavBar()
	renderItalicTitle()
	renderEmptyRowCategories()
	renderTrackingCategories()
	cleanInfobox()
end

-- Specify the overall layout of the infobox, with special settings if the
-- infobox is used as a 'child' inside another infobox.
local function _infobox()
	if args.child ~= 'yes' then
		root = mw.html.create('table')

		root
			:addClass(args.subbox == 'yes' and 'infobox-subbox' or 'infobox')
			:addClass(args.bodyclass)
			-- @deprecated next; target .infobox-<name>
			:cssText(args.bodystyle)
		
		has_list_class({ args.bodyclass })

		renderTitle()
		renderAboveRow()
	else
		root = mw.html.create()

		root
			:wikitext(args.title)
	end
	structure_infobox_common()
	
	return loadTemplateStyles() .. root
end

-- 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.
local function preprocessSingleArg(argName)
	if origArgs[argName] and origArgs[argName] ~= '' then
		args[argName] = origArgs[argName]
	end
end

-- 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.
local function preprocessArgs(prefixTable, step)
	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') 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 a = 1 -- Counter variable.
	local moreArgumentsExist = true
	while moreArgumentsExist == true do
		moreArgumentsExist = false
		for i = a, a + step - 1 do
			for j,v in ipairs(prefixTable) do
				local prefixArgName = v.prefix .. tostring(i)
				if origArgs[prefixArgName] then
					-- Do another loop if any arguments are found, even blank ones.
					moreArgumentsExist = true
					preprocessSingleArg(prefixArgName)
				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 j,dependValue in ipairs(v.depend) do
						local dependArgName = dependValue .. tostring(i)
						preprocessSingleArg(dependArgName)
					end
				end
			end
		end
		a = a + step
	end
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.
local function parseDataParameters()

	preprocessSingleArg('autoheaders')
	preprocessSingleArg('child')
	preprocessSingleArg('bodyclass')
	preprocessSingleArg('subbox')
	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')
	preprocessArgs({
		{prefix = 'image', depend = {'caption', 'imagerowclass'}}
	}, 10)
	preprocessSingleArg('captionstyle')
	preprocessSingleArg('imagestyle')
	preprocessSingleArg('imageclass')
	preprocessArgs({
		{prefix = 'header'},
		{prefix = 'data', depend = {'label'}},
		{prefix = 'rowclass'},
		{prefix = 'rowstyle'},
		{prefix = 'rowcellstyle'},
		{prefix = 'class'}
	}, 50)
	preprocessSingleArg('headerclass')
	preprocessSingleArg('headerstyle')
	preprocessSingleArg('labelstyle')
	preprocessSingleArg('datastyle')
	preprocessSingleArg('below')
	preprocessSingleArg('belowclass')
	preprocessSingleArg('belowstyle')
	preprocessSingleArg('name')
	-- different behaviour for italics if blank or absent
	args['italic title'] = origArgs['italic title']
	preprocessSingleArg('decat')
	preprocessSingleArg('templatestyles')
	preprocessSingleArg('child templatestyles')
	preprocessSingleArg('grandchild templatestyles')
end

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

-- For calling via #invoke within a template
function p.infoboxTemplate(frame)
	origArgs = {}
	for k,v in pairs(frame.args) do origArgs[k] = mw.text.trim(v) end
	
	parseDataParameters()
	
	return _infobox()
end
return p
无垢是什么意思 韩五行属什么的 生普属于什么茶 榴莲有什么功效 妊娠阴性是什么意思
包饺子什么意思 和田玉和翡翠有什么区别 什么时候有胎动 小县城适合做什么生意 枸杞加什么泡水喝壮阳
为什么痛风就痛一只脚 罗嘉良为什么娶苏岩 营业执照什么时候年审 辐射对称是什么意思 湿疹为什么一热就出来
梦见男婴儿是什么意思 清心寡欲下一句是什么 白天不咳嗽晚上咳嗽吃什么药 一事无成是什么生肖 小麦淀粉是什么
洋气是什么意思hcv9jop4ns8r.cn 舐犊是什么意思hcv9jop4ns4r.cn 手上蜕皮是什么原因hcv9jop6ns1r.cn 八项规定的内容是什么hcv7jop9ns8r.cn 一什么景象hcv8jop2ns4r.cn
佛历是什么意思imcecn.com 吃东西就打嗝是什么原因hcv8jop4ns4r.cn 三月是什么季节hcv9jop7ns9r.cn 槟榔肝是由什么引起的hcv7jop7ns0r.cn 倒牙是什么意思hcv7jop6ns2r.cn
檀是什么意思hcv9jop5ns1r.cn xy是什么意思hlguo.com 舌头有裂纹是什么病hcv7jop5ns2r.cn 吃小米粥有什么好处和坏处hcv8jop9ns6r.cn 月经量太少是什么原因引起的hcv7jop9ns0r.cn
13朵玫瑰代表什么意思hcv9jop5ns2r.cn 口干舌燥什么原因hcv9jop2ns9r.cn 什么是动态口令cl108k.com 心花怒放是什么意思hcv9jop1ns8r.cn 疱疹是什么原因引起hcv9jop3ns8r.cn
百度