Zelda Wiki

Want to contribute to this wiki?
Sign up for an account, and get started!

Come join the Zelda Wiki community Discord server!

READ MORE

Zelda Wiki

This module is for producing wikitext. See also Module:UtilsLayout.

This module exports the following functions.

Formatting

bold

bold(text)

Parameters

  • text
    The text to bold.

Returns

  • The bolded text.

Examples

#InputOutputResultStatus
1
bold("Fooloo Limpah")
"<b>Fooloo Limpah</b>"
Fooloo Limpah
Green check

caption

caption(text)

Returns

  • Text in caption font, which is slightly smaller.

Examples

#InputOutputResultStatus
2
caption("Fooloo Limpah")
'<span class="caption">Fooloo Limpah</span>'
Fooloo Limpah
Green check

class

class(class, text)

Returns

  • Text wrapped in a span tag with the given class string.

Examples

#InputOutputResultStatus
3
class("term error", "Fooloo Limpah")
'<span class="term error">Fooloo Limpah</span>'
Fooloo Limpah
Green check

code

code(text)

Parameters

  • text
    The text to render monospaced.

Returns

  • The formatted text.

Examples

#InputOutputResultStatus
4
code("code stuff")
"<code>code stuff</code>"
code stuff
Green check

heading

heading(level, text)

Parameters

Returns

  • string of text for the heading

Examples

#InputOutputStatus
5
heading(2, "Section")
"\n==Section==\n"
Green check
6
heading(3, "Sub-section")
"\n===Sub-section===\n"
Green check

italic

italic(text)

Parameters

  • text
    The text to italicize.

Returns

  • The italicized text.

Examples

#InputOutputResultStatus
7
italic("Fooloo Limpah")
"<i>Fooloo Limpah</i>"
Fooloo Limpah
Green check

inline

inline(text, [options])

Parameters

Returns

  • The formatted text.

Examples

#InputOutputResultStatus
8
inline(
  "Fooloo Limpah",
  {
    bold = true,
    italic = true,
    class = "error",
    tooltip = "Don't steal them!",
  }
)
"<span class=\"error\"><span title=\"Don't steal them!\" class=\"explain\"><b><i>Fooloo Limpah</i></b></span></span>"
Fooloo Limpah
Green check
9
inline(
  "{{Foo}}",
  {
    bold = true,
    nowiki = true,
    code = true,
  }
)
"<b><code>&#123;&#123;Foo&#125;&#125;</code></b>"
{{Foo}}
Green check

lua

lua(text, [options])

Parameters

Returns

  • A block of pre-formatted, syntax-highlighted Lua code

Examples

#InputResult
10
lua("function(foo) \n\t\treturn foo\n\tend")
function(foo) 
		return foo
	end

pre

pre(text, [options])

Parameters

Returns

  • A block of pre-formatted text.

Examples

#InputResult
11
pre("{{List\n\t |foo\n\t |bar\n\t |baz\n\t}}")
{{List
	 |foo
	 |bar
	 |baz
	}}

tooltip

tooltip(baseText, tooltipText, [type])

Parameters

  • baseText
    The text to receive a tooltip.
  • tooltipText
    The text to display on hover.
  • [type]
    If "highlight", colors the base text to make the presence of tooltip text more evident.

Returns

  • Text with a tooltip.

Examples

#InputOutputResultStatus
12
tooltip("hover over me", "hello world!")
'<span title="hello world!" class="explain">hover over me</span>'
hover over me
Green check
13
tooltip("foo", "bar", "highlight")
'<span title="bar" class="explain" style="color:gold">foo</span>'
foo
Green check


Links

anchor

anchor(id, [display])

Parameters

Returns

  • A link that refers to itself. Useful for linking to specific sections of a page without necessarily using headings.

Examples

#InputOutputResultStatus
14
anchor("foo")
'<span id="foo">[[#foo|foo]]</span>'
foo
Green check
15
anchor("bar", "Bar")
'<span id="bar">[[#bar|Bar]]</span>'
Bar
Green check
16
anchor("foo bar")
'<span id="foo bar">[[#foo bar|foo bar]]</span>'
foo bar
Green check

category

category(name, [sortKey])

Parameters

  • name
    The name of the category to link to (with or without namespace prefix).
  • [sortKey]
    A custom sort key for the category entry.

Returns

  • A category link—the kind that adds a category to a page. For the other kind that links to the actual category page, use link.

Examples

#InputOutputStatus
Category link from category name
17
category("Items")
"[[Category:Items]]"
Green check
Category link from category name with namespace prefix
18
category("Category:Items")
"[[Category:Items]]"
Green check
Category link with sort key
19
category("Items", "*")
"[[Category:Items|*]]"
Green check

categories

categories(names)

Parameters

  • names
    An array of category names, with or without the namespace prefix.

Returns

  • A concatenated string of category links.

Examples

#InputOutputStatus
20
categories({"Link", "Category:Zelda", "Category:Ganon"})
"[[Category:Link]][[Category:Zelda]][[Category:Ganon]]"
Green check
21
categories({})
""
Green check

containsLink

containsLink(wikitext)

Returns

  • Given a string of wikitext, returns true if it contains an internal or interwiki link, false otherwise.

Examples

#InputOutputResult
22
containsLink("There is a [[Link]]")
true
Green check
23
containsLink("[Link] is not a link but rather an indication of replaced words in a quote.")
false
Green check

file

file(name, [options])

Parameters

Returns

  • A string of wikitext that renders a thumbnail for the file.

Examples

#InputOutputResultStatus
24
file("File:ALttP Ganon Sprite.png")
"[[File:ALttP Ganon Sprite.png]]"
ALttP Ganon Sprite
Green check
25
file(
  "ALttP Ganon Sprite.png",
  {
    caption = "Ganon",
    link = "",
  }
)
"[[File:ALttP Ganon Sprite.png|link=|Ganon]]"
Ganon
Green check
26
file(
  "File:TWW Great Fairy Figurine Model.png",
  {
    size = "100px",
    link = "Great Fairy",
  }
)
"[[File:TWW Great Fairy Figurine Model.png|100px|link=Great Fairy]]"
TWW Great Fairy Figurine Model
Green check
27
file(
  "File:TWW Great Fairy Figurine Model.png",
  {
    noBacklink = true,
    size = "100px",
    link = "Great Fairy",
  }
)
"[[File:TWW Great Fairy Figurine Model.png|100px|link=https://zelda.fandom.com/wiki/Great_Fairy]]"
TWW Great Fairy Figurine Model
Green check
28
file(
  "File:TWW Great Fairy Figurine Model.png",
  {
    class = "notpageimage",
    size = "100px",
    link = "Great Fairy",
  }
)
"[[File:TWW Great Fairy Figurine Model.png|100px|link=Great Fairy|class=notpageimage]]"
TWW Great Fairy Figurine Model
Green check

killBacklinks

killBacklinks(wikitext)

Parameters

Returns

  • The same wikitext but with all the internal links formatted as external links, to avoid additions to Special:WhatLinksHere.

Examples

#InputOutputResultStatus
Escapes basic article links - unfortunately non-existent pages are not rendered as red links for performance reasons
29
killBacklinks("[[Link]], [[Princess Zelda|Zelda]], and [[Jean-Guy Rubber Boots]]")
'<span class="plainlinks">[https://zelda.fandom.com/Link Link]</span>, <span class="plainlinks">[https://zelda.fandom.com/Princess_Zelda Zelda]</span>, and <span class="plainlinks">[https://zelda.fandom.com/Jean-Guy_Rubber_Boots Jean-Guy Rubber Boots]</span>'
Link, Zelda, and Jean-Guy Rubber Boots
Green check
Does not escape file links or category links
30
killBacklinks("[[Category:Link]] and [[File:SS Blessed Butterfly Icon.png]]")
"[[Category:Link]] and [[File:SS Blessed Butterfly Icon.png]]"
and SS Blessed Butterfly Icon
Green check
Escapes visible file and category links
31
killBacklinks("[[:Category:Link]], [[:Category:Princess Zelda|Zelda]], and [[:File:SS Blessed Butterfly Icon.png]]")
'<span class="plainlinks">[https://zelda.fandom.com/Category:Link Category:Link]</span>, <span class="plainlinks">[https://zelda.fandom.com/Category:Princess_Zelda Zelda]</span>, and <span class="plainlinks">[https://zelda.fandom.com/File:SS_Blessed_Butterfly_Icon.png File:SS Blessed Butterfly Icon.png]</span>'
Category:Link, Zelda, and File:SS Blessed Butterfly Icon.png
Green check
Does not affect interwiki links
32
killBacklinks("[[metroidwiki:Chozo|Chozo]]")
"[[metroidwiki:Chozo|Chozo]]"
Chozo
Green check

link

link(page, [display], [noBacklink])

Parameters

  • page
    The link target. Can be the name of a page on the wiki or an external URL.
  • [display="page"]
    The text to display for the link.
  • [noBacklink]
    When true, renders an internal link such that it does not register on the Special:WhatLinksHere of the target page.

    Use only when certain that the page exists. This method cannot render red-links (i.e. distinguish non-existent pages).

Returns

  • A string of wikitext that evaluates to a link. Will display a red link if the target is an internal link to a page that doesn't exist.

Examples

#InputOutputResultStatus
Internal link
33
link("Princess Zelda")
"[[Princess Zelda]]"
Princess Zelda
Green check
Piped link
34
link("Princess Zelda", "Zelda")
"[[Princess Zelda|Zelda]]"
Zelda
Green check
Category link
35
link("Category:Items")
"[[:Category:Items]]"
Category:Items
Green check
Category link without prefix
36
link("Category:Items", "")
"[[:Category:Items|Items]]"
Items
Green check
Category link with display text
37
link(
  "Category:Items in Breath of the Wild",
  "Items in ''Breath of the Wild''"
)
"[[:Category:Items in Breath of the Wild|Items in ''Breath of the Wild'']]"
Items in Breath of the Wild
Green check
File link (to file description)
38
link("File:MM Deku Butler Artwork.png")
"[[:File:MM Deku Butler Artwork.png]]"
File:MM Deku Butler Artwork.png
Green check
External link
39
link("https://www.mariowiki.com/Thwomp", "Thwomp")
"[https://www.mariowiki.com/Thwomp Thwomp]"
Thwomp
Green check
Looks like an internal link, but it's actually an external link. This is to avoid Special:WhatLinksHere
40
link("Princess Zelda", "Zelda", true)
'<span class="plainlinks">[https://zelda.fandom.com/Princess_Zelda Zelda]</span>'
Zelda
Green check
When noBacklink is set to true, red links are not rendered for pages which do not exist, for performance reasons.
41
link("Flippityfloppityfloo", nil, true)
'<span class="plainlinks">[https://zelda.fandom.com/Flippityfloppityfloo Flippityfloppityfloo]</span>'
Flippityfloppityfloo
Green check

sectionLink

sectionLink(page, [section], [display])

Parameters

Returns

  • A string of wikitext rendering a section link.

Examples

#InputOutputResultStatus
42
sectionLink("Link", "Ocarina of Time", "Hero of Time")
"[[Link#Ocarina of Time|Hero of Time]]"
Hero of Time
Green check
43
sectionLink("Link", nil, "Hero of Time")
"[[Link|Hero of Time]]"
Hero of Time
Green check
44
sectionLink("Link", "")
"[[Link#]]"
Link#
Green check

stripCategories

stripCategories(wikitext)

Parameters

Returns

  • The string of wiki markup with all the category links removed (not including visual links to category description pages).
  • A table array of direct links to the removed categories.

Examples

#InputOutputStatus
Basic use case
45
stripCategories("<[[Category:Link]][[Category:Princess Zelda]][[Category:Link]]>")
"<>"
Green check
{
  "[[:Category:Link]]",
  "[[:Category:Princess Zelda]]",
}
Green check
Does not affect visual links to category description pages
46
stripCategories("[[:Category:Link]] and [[:Category:Princess Zelda]]")
"[[:Category:Link]] and [[:Category:Princess Zelda]]"
Green check
{}
Green check


Lists

list

list(items)

Parameters

  • items
    An array of strings (list items).

Returns

  • An unordered list with the plainlist class.

Examples

#InputOutputResultStatus
47
list({})
""
Green check
48
list({"single item"})
'<ul class="plainlist"><li>single item</li></ul>'
  • single item
Green check
49
list({"multiple", "items", ""})
'<ul class="plainlist"><li>multiple</li><li>items</li><li></li></ul>'
  • multiple
  • items
Green check

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

#InputOutputResultStatus
50
bulletList({})
""
Green check
51
bulletList({"single item"})
"<ul><li>single item</li></ul>"
  • single item
Green check
52
bulletList({"multiple", "items", ""})
"<ul><li>multiple</li><li>items</li><li></li></ul>"
  • multiple
  • items
Green check
53
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>'
  • list
    • with
      • nested
      • items
    • inside
Green check

numberList

numberList(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.
    [start]
    Sets the starting value.

Returns

  • A string representation of an ordered list using HTML syntax.

Examples

#InputOutputResultStatus
54
numberList({})
""
Green check
55
numberList({"single item"})
"<ol><li>single item</li></ol>"
  1. single item
Green check
56
numberList({"multiple", "items", ""})
"<ol><li>multiple</li><li>items</li><li></li></ol>"
  1. multiple
  2. items
Green check
57
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>"
  1. list
    1. with
      1. nested
      2. items
    2. inside
Green check
58
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>'
  1. Eight
  2. Nine
  3. Ten
Green check

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

#InputResultStatus
59
definitionList({})
Green check
60
definitionList({
  {"key1", "value1"},
})
key1
value1
Green check
61
definitionList({
  {"key1", "value1"},
  {"key2", "value2"},
})
key1
value1
key2
value2
Green check
62
definitionList({
  {"", "value1"},
  {[2] = "value2" },
  {"key3", ""},
  {"key4"},
})
value1
value2
key3
key4
Green check
63
definitionList({
  {
    "key 1",
    {
      {
        "key 1.1",
        {
          {"key 1.1.1", "value 1.1.1"},
        },
      },
      {"key 1.2", "value 1.2"},
    },
  },
  {"key2", "value2"},
})
key 1
key 1.1
key 1.1.1
value 1.1.1
key 1.2
value 1.2
key2
value2
Green check
64
definitionList(
  {
    {
      "key 1",
      "value 1.1",
      {
        {"key 1.1", "value 1.2"},
        {"key 1.2", "value 1.2"},
      },
    },
  },
  { class = "custom-class" }
)
key 1
value 1.1
key 1.1
value 1.2
key 1.2
value 1.2
Green check

local utilsPackage = require("Module:UtilsPackage")

return utilsPackage.submodules({
	"Module:UtilsMarkup/Format",
	"Module:UtilsMarkup/Link",
	"Module:UtilsMarkup/List",
}, {
	"Formatting", 
	"Links",
	"Lists",
})