Editing
Module:List
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
Advanced
Special characters
Help
Heading
Level 2
Level 3
Level 4
Level 5
Format
Insert
Latin
Latin extended
IPA
Symbols
Greek
Greek extended
Cyrillic
Arabic
Arabic extended
Hebrew
Bangla
Tamil
Telugu
Sinhala
Devanagari
Gujarati
Thai
Lao
Khmer
Canadian Aboriginal
Runes
ร
รก
ร
ร
ร
รข
ร
รค
ร
รฃ
ว
ว
ฤ
ฤ
ฤ
ฤ
ฤ
ฤ
ร
รฅ
ฤ
ฤ
ฤ
ฤ
ร
รง
ฤ
ฤ
ฤ
ฤ
ฤ
ฤ
ฤ
ฤ
ร
รฉ
ร
รจ
ร
รช
ร
รซ
ฤ
ฤ
ฤ
ฤ
ฤ
ฤ
ฤ
ฤ
ฤ
ฤ
ฤ
ฤ
ฤข
ฤฃ
ฤ
ฤ
ฤ
ฤก
ฤค
ฤฅ
ฤฆ
ฤง
ร
รญ
ร
รฌ
ร
รฎ
ร
รฏ
ฤจ
ฤฉ
ว
ว
ฤช
ฤซ
ฤฌ
ฤญ
ฤฐ
ฤฑ
ฤฎ
ฤฏ
ฤด
ฤต
ฤถ
ฤท
ฤน
ฤบ
ฤป
ฤผ
ฤฝ
ฤพ
ล
ล
ล
ล
ร
รฑ
ล
ล
ล
ล
ร
รณ
ร
รฒ
ร
รด
ร
รถ
ร
รต
ว
ว
ล
ล
ล
ล
วช
วซ
ล
ล
ล
ล
ล
ล
ล
ล
ล
ล
ล
ล
ล
ล
ล
ลก
ศ
ศ
ศ
ศ
ลค
ลฅ
ร
รบ
ร
รน
ร
รป
ร
รผ
ลจ
ลฉ
ลฎ
ลฏ
ว
ว
ลช
ลซ
ว
ว
ว
ว
ลฌ
ลญ
ลฒ
ลณ
ลฐ
ลฑ
ลด
ลต
ร
รฝ
ลถ
ลท
ลธ
รฟ
ศฒ
ศณ
ลน
ลบ
ลฝ
ลพ
ลป
ลผ
ร
รฆ
วข
วฃ
ร
รธ
ล
ล
ร
ร
รฐ
ร
รพ
ฦ
ษ
Formatting
Links
Headings
Lists
Files
References
Discussion
Description
What you type
What you get
Italic
''Italic text''
Italic text
Bold
'''Bold text'''
Bold text
Bold & italic
'''''Bold & italic text'''''
Bold & italic text
local libUtil = require('libraryUtil') local checkType = libUtil.checkType local mTableTools = require('Module:TableTools') local p = {} local listTypes = { ['bulleted'] = true, ['unbulleted'] = true, ['horizontal'] = true, ['ordered'] = true, ['horizontal_ordered'] = true } function p.makeListData(listType, args) -- Constructs a data table to be passed to p.renderList. local data = {} -- Classes and TemplateStyles data.classes = {} data.templatestyles = '' if listType == 'horizontal' or listType == 'horizontal_ordered' then table.insert(data.classes, 'hlist') data.templatestyles = mw.getCurrentFrame():extensionTag{ name = 'templatestyles', args = { src = 'Hlist/styles.css' } } elseif listType == 'unbulleted' then table.insert(data.classes, 'plainlist') data.templatestyles = mw.getCurrentFrame():extensionTag{ name = 'templatestyles', args = { src = 'Plainlist/styles.css' } } end table.insert(data.classes, args.class) -- Main div style data.style = args.style -- Indent for horizontal lists if listType == 'horizontal' or listType == 'horizontal_ordered' then local indent = tonumber(args.indent) indent = indent and indent * 1.6 or 0 if indent > 0 then data.marginLeft = indent .. 'em' end end -- List style types for ordered lists -- This could be "1, 2, 3", "a, b, c", or a number of others. The list style -- type is either set by the "type" attribute or the "list-style-type" CSS -- property. if listType == 'ordered' or listType == 'horizontal_ordered' then data.listStyleType = args.list_style_type or args['list-style-type'] data.type = args['type'] -- Detect invalid type attributes and attempt to convert them to -- list-style-type CSS properties. if data.type and not data.listStyleType and not tostring(data.type):find('^%s*[1AaIi]%s*$') then data.listStyleType = data.type data.type = nil end end -- List tag type if listType == 'ordered' or listType == 'horizontal_ordered' then data.listTag = 'ol' else data.listTag = 'ul' end -- Start number for ordered lists data.start = args.start if listType == 'horizontal_ordered' then -- Apply fix to get start numbers working with horizontal ordered lists. local startNum = tonumber(data.start) if startNum then data.counterReset = 'listitem ' .. tostring(startNum - 1) end end -- List style -- ul_style and ol_style are included for backwards compatibility. No -- distinction is made for ordered or unordered lists. data.listStyle = args.list_style -- List items -- li_style is included for backwards compatibility. item_style was included -- to be easier to understand for non-coders. data.itemStyle = args.item_style or args.li_style data.items = {} for _, num in ipairs(mTableTools.numKeys(args)) do local item = {} item.content = args[num] item.style = args['item' .. tostring(num) .. '_style'] or args['item_style' .. tostring(num)] item.value = args['item' .. tostring(num) .. '_value'] or args['item_value' .. tostring(num)] table.insert(data.items, item) end return data end function p.renderList(data) -- Renders the list HTML. -- Return the blank string if there are no list items. if type(data.items) ~= 'table' or #data.items < 1 then return '' end -- Render the main div tag. local root = mw.html.create('div') for _, class in ipairs(data.classes or {}) do root:addClass(class) end root:css{['margin-left'] = data.marginLeft} if data.style then root:cssText(data.style) end -- Render the list tag. local list = root:tag(data.listTag or 'ul') list :attr{start = data.start, type = data.type} :css{ ['counter-reset'] = data.counterReset, ['list-style-type'] = data.listStyleType } if data.listStyle then list:cssText(data.listStyle) end -- Render the list items for _, t in ipairs(data.items or {}) do local item = list:tag('li') if data.itemStyle then item:cssText(data.itemStyle) end if t.style then item:cssText(t.style) end item :attr{value = t.value} :wikitext(t.content) end return data.templatestyles .. tostring(root) end function p.renderTrackingCategories(args) local isDeprecated = false -- Tracks deprecated parameters. for k, v in pairs(args) do k = tostring(k) if k:find('^item_style%d+$') or k:find('^item_value%d+$') then isDeprecated = true break end end local ret = '' if isDeprecated then ret = ret .. '[[Category:List templates with deprecated parameters]]' end return ret end function p.makeList(listType, args) if not listType or not listTypes[listType] then error(string.format( "bad argument #1 to 'makeList' ('%s' is not a valid list type)", tostring(listType) ), 2) end checkType('makeList', 2, args, 'table') local data = p.makeListData(listType, args) local list = p.renderList(data) local trackingCategories = p.renderTrackingCategories(args) return list .. trackingCategories end for listType in pairs(listTypes) do p[listType] = function (frame) local mArguments = require('Module:Arguments') local origArgs = mArguments.getArgs(frame, { frameOnly = ((frame and frame.args and frame.args.frameonly or '') ~= ''), valueFunc = function (key, value) if not value or not mw.ustring.find(value, '%S') then return nil end if mw.ustring.find(value, '^%s*[%*#;:]') then return value else return value:match('^%s*(.-)%s*$') end return nil end }) -- Copy all the arguments to a new table, for faster indexing. local args = {} for k, v in pairs(origArgs) do args[k] = v end return p.makeList(listType, args) end end return p
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
local
libUtil
=
require
(
'libraryUtil'
)
local
checkType
=
libUtil
.
checkType
local
mTableTools
=
require
(
'Module:TableTools'
)
local
p
=
{
}
local
listTypes
=
{
[
'bulleted'
]
=
true
,
[
'unbulleted'
]
=
true
,
[
'horizontal'
]
=
true
,
[
'ordered'
]
=
true
,
[
'horizontal_ordered'
]
=
true
}
function
p
.
makeListData
(
listType
,
args
)
-- Constructs a data table to be passed to p.renderList.
local
data
=
{
}
-- Classes and TemplateStyles
data
.
classes
=
{
}
ืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืื
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0
0
0
1:0
Edit summary
(Briefly describe your changes)
Please note that all contributions to Chabadpedia are considered to be released under the GNU Free Documentation License 1.3 or later (see
Chabadpedia:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Debug console
* The module exports are available as the variable "p", including unsaved modifications. * Precede a line with "=" to evaluate it as an expression or use print(). Use mw.logObject() for tables. * Use mw.log() and mw.logObject() in module code to send messages to this console.
Module:List/doc
(
edit
)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Module
Discussion
English
Views
Read
Edit source
View history
More
Navigation
Main page
Recent changes
Random page
Tools
What links here
Related changes
Special pages
Page information