This is the documentation page for Module:UtilsMarkup/List
This module exports the following functions.
list
list(items)
Parameters
items
- An array of strings (list items).
Returns
- An unordered list with the
plainlist
class.
Examples
# | Input | Output | Result | Status |
---|---|---|---|---|
1 | list({})
| "" | ||
2 | list({"single item"})
| '<ul class="plainlist"><li>single item</li></ul>' |
| |
3 | list({"multiple", "items", ""})
| '<ul class="plainlist"><li>multiple</li><li>items</li><li></li></ul>' |
|
bulletList
bulletList(items, [attributes])
Parameters
items
- An array of strings (list items).
[attributes]
[class]
- Sets the
class
attribute of HTML list tag. Note that this is recursively applied to sub-lists.
Returns
- A string representation of an unordered list using HTML syntax.
Examples
# | Input | Output | Result | Status |
---|---|---|---|---|
4 | bulletList({})
| "" | ||
5 | bulletList({"single item"})
| "<ul><li>single item</li></ul>" |
| |
6 | bulletList({"multiple", "items", ""})
| "<ul><li>multiple</li><li>items</li><li></li></ul>" |
| |
7 | bulletList(
{
"list",
{
"with",
{"nested", "items"},
"inside",
},
},
{ class = "custom-class" }
)
| '<ul class="custom-class"><li>list</li><ul class="custom-class"><li>with</li><ul class="custom-class"><li>nested</li><li>items</li></ul><li>inside</li></ul></ul>' |
|
numberList
numberList(items, [attributes])
Parameters
items
- An array of strings (list items).
Returns
- A string representation of an ordered list using HTML syntax.
Examples
# | Input | Output | Result | Status |
---|---|---|---|---|
8 | numberList({})
| "" | ||
9 | numberList({"single item"})
| "<ol><li>single item</li></ol>" |
| |
10 | numberList({"multiple", "items", ""})
| "<ol><li>multiple</li><li>items</li><li></li></ol>" |
| |
11 | numberList({
"list",
{
"with",
{"nested", "items"},
"inside",
},
})
| "<ol><li>list</li><ol><li>with</li><ol><li>nested</li><li>items</li></ol><li>inside</li></ol></ol>" |
| |
12 | numberList(
{"Eight", "Nine", "Ten"},
{
start = 8,
class = "custom-class",
}
)
| '<ol start="8" class="custom-class"><li>Eight</li><li>Nine</li><li>Ten</li></ol>' |
|
definitionList
definitionList(pairs, [attributes])
Parameters
pairs
- Array of
table
of pairs where the first pair item is a term and the value is a definition.
[attributes]
[class]
- Sets the
class
attribute of HTML list tag. Note that this is recursively applied to sub-lists.
Returns
- A string representation of a definition list using HTML syntax.
Examples
# | Input | Result | Status |
---|---|---|---|
13 | definitionList({})
| ||
14 | definitionList({
{"key1", "value1"},
})
|
| |
15 | definitionList({
{"key1", "value1"},
{"key2", "value2"},
})
|
| |
16 | definitionList({
{"", "value1"},
{[2] = "value2" },
{"key3", ""},
{"key4"},
})
|
| |
17 | definitionList({
{
"key 1",
{
{
"key 1.1",
{
{"key 1.1.1", "value 1.1.1"},
},
},
{"key 1.2", "value 1.2"},
},
},
{"key2", "value2"},
})
|
| |
18 | definitionList(
{
{
"key 1",
"value 1.1",
{
{"key 1.1", "value 1.2"},
{"key 1.2", "value 1.2"},
},
},
},
{ class = "custom-class" }
)
|
|