<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-Hans-CN">
	<id>https://wiki.statsape.com/index.php?action=history&amp;feed=atom&amp;title=%E6%A8%A1%E5%9D%97%3AList</id>
	<title>模块:List - 版本历史</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.statsape.com/index.php?action=history&amp;feed=atom&amp;title=%E6%A8%A1%E5%9D%97%3AList"/>
	<link rel="alternate" type="text/html" href="https://wiki.statsape.com/index.php?title=%E6%A8%A1%E5%9D%97:List&amp;action=history"/>
	<updated>2026-04-04T09:37:16Z</updated>
	<subtitle>本wiki上该页面的版本历史</subtitle>
	<generator>MediaWiki 1.39.6</generator>
	<entry>
		<id>https://wiki.statsape.com/index.php?title=%E6%A8%A1%E5%9D%97:List&amp;diff=498&amp;oldid=prev</id>
		<title>Zeroclanzhang：​创建页面，内容为“-- This module outputs different kinds of lists. At the moment, bulleted, -- unbulleted, horizontal, ordered, and horizontal ordered lists are supported.  local libUtil = require(&#039;libraryUtil&#039;) local checkType = libUtil.checkType local mTableTools = require(&#039;Module:TableTools&#039;)  local p = {}  local listTypes = { 	[&#039;bulleted&#039;] = true, 	[&#039;unbulleted&#039;] = true, 	[&#039;horizontal&#039;] = true, 	[&#039;ordered&#039;] = true, 	[&#039;horizontal_ordered&#039;] = true }  function p.makeListData(li…”</title>
		<link rel="alternate" type="text/html" href="https://wiki.statsape.com/index.php?title=%E6%A8%A1%E5%9D%97:List&amp;diff=498&amp;oldid=prev"/>
		<updated>2023-07-13T14:05:21Z</updated>

		<summary type="html">&lt;p&gt;创建页面，内容为“-- This module outputs different kinds of lists. At the moment, bulleted, -- unbulleted, horizontal, ordered, and horizontal ordered lists are supported.  local libUtil = require(&amp;#039;libraryUtil&amp;#039;) local checkType = libUtil.checkType local mTableTools = require(&amp;#039;Module:TableTools&amp;#039;)  local p = {}  local listTypes = { 	[&amp;#039;bulleted&amp;#039;] = true, 	[&amp;#039;unbulleted&amp;#039;] = true, 	[&amp;#039;horizontal&amp;#039;] = true, 	[&amp;#039;ordered&amp;#039;] = true, 	[&amp;#039;horizontal_ordered&amp;#039;] = true }  function p.makeListData(li…”&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- This module outputs different kinds of lists. At the moment, bulleted,&lt;br /&gt;
-- unbulleted, horizontal, ordered, and horizontal ordered lists are supported.&lt;br /&gt;
&lt;br /&gt;
local libUtil = require(&amp;#039;libraryUtil&amp;#039;)&lt;br /&gt;
local checkType = libUtil.checkType&lt;br /&gt;
local mTableTools = require(&amp;#039;Module:TableTools&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
local listTypes = {&lt;br /&gt;
	[&amp;#039;bulleted&amp;#039;] = true,&lt;br /&gt;
	[&amp;#039;unbulleted&amp;#039;] = true,&lt;br /&gt;
	[&amp;#039;horizontal&amp;#039;] = true,&lt;br /&gt;
	[&amp;#039;ordered&amp;#039;] = true,&lt;br /&gt;
	[&amp;#039;horizontal_ordered&amp;#039;] = true&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function p.makeListData(listType, args)&lt;br /&gt;
	-- Constructs a data table to be passed to p.renderList.&lt;br /&gt;
	local data = {}&lt;br /&gt;
&lt;br /&gt;
	-- Classes&lt;br /&gt;
	data.classes = {}&lt;br /&gt;
	if listType == &amp;#039;horizontal&amp;#039; or listType == &amp;#039;horizontal_ordered&amp;#039; then&lt;br /&gt;
		table.insert(data.classes, &amp;#039;hlist&amp;#039;)&lt;br /&gt;
	elseif listType == &amp;#039;unbulleted&amp;#039; then&lt;br /&gt;
		table.insert(data.classes, &amp;#039;plainlist&amp;#039;)&lt;br /&gt;
	end&lt;br /&gt;
	table.insert(data.classes, args.class)&lt;br /&gt;
&lt;br /&gt;
	-- Main div style&lt;br /&gt;
	data.style = args.style&lt;br /&gt;
&lt;br /&gt;
	-- Indent for horizontal lists&lt;br /&gt;
	if listType == &amp;#039;horizontal&amp;#039; or listType == &amp;#039;horizontal_ordered&amp;#039; then&lt;br /&gt;
		local indent = tonumber(args.indent)&lt;br /&gt;
		indent = indent and indent * 1.6 or 0&lt;br /&gt;
		if indent &amp;gt; 0 then&lt;br /&gt;
			data.marginLeft = indent .. &amp;#039;em&amp;#039;&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- List style types for ordered lists&lt;br /&gt;
	-- This could be &amp;quot;1, 2, 3&amp;quot;, &amp;quot;a, b, c&amp;quot;, or a number of others. The list style&lt;br /&gt;
	-- type is either set by the &amp;quot;type&amp;quot; attribute or the &amp;quot;list-style-type&amp;quot; CSS&lt;br /&gt;
	-- property.&lt;br /&gt;
	if listType == &amp;#039;ordered&amp;#039; or listType == &amp;#039;horizontal_ordered&amp;#039; then &lt;br /&gt;
		data.listStyleType = args.list_style_type or args[&amp;#039;list-style-type&amp;#039;]&lt;br /&gt;
		data.type = args[&amp;#039;type&amp;#039;]&lt;br /&gt;
&lt;br /&gt;
		-- Detect invalid type attributes and attempt to convert them to&lt;br /&gt;
		-- list-style-type CSS properties.&lt;br /&gt;
		if data.type &lt;br /&gt;
			and not data.listStyleType&lt;br /&gt;
			and not tostring(data.type):find(&amp;#039;^%s*[1AaIi]%s*$&amp;#039;)&lt;br /&gt;
		then&lt;br /&gt;
			data.listStyleType = data.type&lt;br /&gt;
			data.type = nil&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- List tag type&lt;br /&gt;
	if listType == &amp;#039;ordered&amp;#039; or listType == &amp;#039;horizontal_ordered&amp;#039; then&lt;br /&gt;
		data.listTag = &amp;#039;ol&amp;#039;&lt;br /&gt;
	else&lt;br /&gt;
		data.listTag = &amp;#039;ul&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Start number for ordered lists&lt;br /&gt;
	data.start = args.start&lt;br /&gt;
	if listType == &amp;#039;horizontal_ordered&amp;#039; then&lt;br /&gt;
		-- Apply fix to get start numbers working with horizontal ordered lists.&lt;br /&gt;
		local startNum = tonumber(data.start)&lt;br /&gt;
		if startNum then&lt;br /&gt;
			data.counterReset = &amp;#039;listitem &amp;#039; .. tostring(startNum - 1)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- List style&lt;br /&gt;
	 -- ul_style and ol_style are included for backwards compatibility. No&lt;br /&gt;
	 -- distinction is made for ordered or unordered lists.&lt;br /&gt;
	data.listStyle = args.list_style&lt;br /&gt;
&lt;br /&gt;
	-- List items&lt;br /&gt;
	-- li_style is included for backwards compatibility. item_style was included&lt;br /&gt;
	-- to be easier to understand for non-coders.&lt;br /&gt;
	data.itemStyle = args.item_style or args.li_style&lt;br /&gt;
	data.items = {}&lt;br /&gt;
	for i, num in ipairs(mTableTools.numKeys(args)) do&lt;br /&gt;
		local item = {}&lt;br /&gt;
		item.content = args[num]&lt;br /&gt;
		item.style = args[&amp;#039;item&amp;#039; .. tostring(num) .. &amp;#039;_style&amp;#039;]&lt;br /&gt;
			or args[&amp;#039;item_style&amp;#039; .. tostring(num)]&lt;br /&gt;
		item.value = args[&amp;#039;item&amp;#039; .. tostring(num) .. &amp;#039;_value&amp;#039;]&lt;br /&gt;
			or args[&amp;#039;item_value&amp;#039; .. tostring(num)]&lt;br /&gt;
		table.insert(data.items, item)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return data&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.renderList(data)&lt;br /&gt;
	-- Renders the list HTML.&lt;br /&gt;
	&lt;br /&gt;
	-- Return the blank string if there are no list items.&lt;br /&gt;
	if type(data.items) ~= &amp;#039;table&amp;#039; or #data.items &amp;lt; 1 then&lt;br /&gt;
		return &amp;#039;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- Render the main div tag.&lt;br /&gt;
	local root = mw.html.create(&amp;#039;div&amp;#039;)&lt;br /&gt;
	for i, class in ipairs(data.classes or {}) do&lt;br /&gt;
		root:addClass(class)&lt;br /&gt;
	end&lt;br /&gt;
	root:css{[&amp;#039;margin-left&amp;#039;] = data.marginLeft}&lt;br /&gt;
	if data.style then&lt;br /&gt;
		root:cssText(data.style)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Render the list tag.&lt;br /&gt;
	local list = root:tag(data.listTag or &amp;#039;ul&amp;#039;)&lt;br /&gt;
	list&lt;br /&gt;
		:attr{start = data.start, type = data.type}&lt;br /&gt;
		:css{&lt;br /&gt;
			[&amp;#039;counter-reset&amp;#039;] = data.counterReset,&lt;br /&gt;
			[&amp;#039;list-style-type&amp;#039;] = data.listStyleType&lt;br /&gt;
		}&lt;br /&gt;
	if data.listStyle then&lt;br /&gt;
		list:cssText(data.listStyle)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Render the list items&lt;br /&gt;
	for i, t in ipairs(data.items or {}) do&lt;br /&gt;
		local item = list:tag(&amp;#039;li&amp;#039;)&lt;br /&gt;
		if data.itemStyle then&lt;br /&gt;
			item:cssText(data.itemStyle)&lt;br /&gt;
		end&lt;br /&gt;
		if t.style then&lt;br /&gt;
			item:cssText(t.style)&lt;br /&gt;
		end&lt;br /&gt;
		item&lt;br /&gt;
			:attr{value = t.value}&lt;br /&gt;
			:wikitext(t.content)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return tostring(root)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.renderTrackingCategories(args)&lt;br /&gt;
	local isDeprecated = false -- Tracks deprecated parameters.&lt;br /&gt;
	for k, v in pairs(args) do&lt;br /&gt;
		k = tostring(k)&lt;br /&gt;
		if k:find(&amp;#039;^item_style%d+$&amp;#039;) or k:find(&amp;#039;^item_value%d+$&amp;#039;) then&lt;br /&gt;
			isDeprecated = true&lt;br /&gt;
			break&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	local ret = &amp;#039;&amp;#039;&lt;br /&gt;
	if isDeprecated then&lt;br /&gt;
		ret = ret .. &amp;#039;[[Category:List templates with deprecated parameters]]&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	return ret&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.makeList(listType, args)&lt;br /&gt;
	if not listType or not listTypes[listType] then&lt;br /&gt;
		error(string.format(&lt;br /&gt;
			&amp;quot;bad argument #1 to &amp;#039;makeList&amp;#039; (&amp;#039;%s&amp;#039; is not a valid list type)&amp;quot;,&lt;br /&gt;
			tostring(listType)&lt;br /&gt;
		), 2)&lt;br /&gt;
	end&lt;br /&gt;
	checkType(&amp;#039;makeList&amp;#039;, 2, args, &amp;#039;table&amp;#039;)&lt;br /&gt;
	local data = p.makeListData(listType, args)&lt;br /&gt;
	local list = p.renderList(data)&lt;br /&gt;
	local trackingCategories = p.renderTrackingCategories(args)&lt;br /&gt;
	return list .. trackingCategories&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
for listType in pairs(listTypes) do&lt;br /&gt;
	p[listType] = function (frame)&lt;br /&gt;
		local mArguments = require(&amp;#039;Module:Arguments&amp;#039;)&lt;br /&gt;
		local origArgs = mArguments.getArgs(frame)&lt;br /&gt;
		-- Copy all the arguments to a new table, for faster indexing.&lt;br /&gt;
		local args = {}&lt;br /&gt;
		for k, v in pairs(origArgs) do&lt;br /&gt;
			args[k] = v&lt;br /&gt;
		end&lt;br /&gt;
		return p.makeList(listType, args)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Zeroclanzhang</name></author>
	</entry>
</feed>