forked from pokemoncentral/wiki-lua-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSup.lua
54 lines (39 loc) · 1.46 KB
/
Sup.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
--[[
This module creates link to games, displaying them in superscripts with
colored abbreviations.
Examples:
{{#invoke: Sup | UL }}
{{#invoke: Sup | RZS | RFVF}}
{{#invoke: Sup | HGSS | XY | ROZA }}
HINT: If you get an Errore Script, try to split an abbreviation into smaller
parts. For example:
{{#invoke: Sup | OACPtHGSS }} --> {{#invoke: Sup | OAC | Pt | HGSS }}
However, this doesn't work if the first abbreviation is not constant, for
example if it's a parameter in a template. In that case, you can use the
_abbr function to pass all the abbreviations as parameters:
{{#invoke: Sup | _abbr | {{{1}}} }}
--]]
local lib = require('Wikilib-sigle')
-- Creates the links for a single abbreviation, as a single string
local makeLinks = function(data)
return table.concat(lib.coloredAbbrLinks(data, lib.bolden))
end
-- Wraps a list of links content in sup tags
local makeSup = function(links)
table.insert(links, 1, '<sup>')
table.insert(links, '</sup>')
return table.concat(links)
end
-- Dynamically generated Wikicode interface
local sup = lib.mapAbbrs(function(_, abbr)
--[[
Wikicode arguments are first processed one-by-one by makeLinks,
resulting in a table having a string for every argument, containing
all the links. These strings are then concatenated and wrapped in sup
tags by makeSup.
--]]
return lib.onMergedAbbrs(abbr, makeLinks, makeSup)
end)
-- Adding _abbr proxy function
lib.proxy(sup)
return sup