forked from Liquipedia/Lua-Modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhotkey.lua
More file actions
42 lines (36 loc) · 1.03 KB
/
Copy pathhotkey.lua
File metadata and controls
42 lines (36 loc) · 1.03 KB
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
---
-- @Liquipedia
-- wiki=commons
-- page=Module:Hotkey
--
-- Please see https://github.com/Liquipedia/Lua-Modules to contribute
--
local Class = require('Module:Class')
local Hotkeys = {}
local _SEPERATORS = {
['->'] = ' → ',
['then'] = ' → ',
['arrow'] = ' → ',
['+'] = ' + ',
['and'] = ' + ',
['&'] = ' + ',
['plus'] = ' + ',
['/'] = ' → ',
['or'] = ' → ',
['forwardslash'] = ' → ',
['slash'] = ' / ',
['space'] = ' ',
['nbsp'] = ' ',
[' '] = ' '
}
function Hotkeys.hotkey(hotkey)
return tostring(mw.html.create('span'):addClass('hotkey-key'):wikitext(hotkey or ''))
end
function Hotkeys.hotkey2(hotkey1, hotkey2, seperator)
hotkey1 = Hotkeys.hotkey(hotkey1)
hotkey2 = Hotkeys.hotkey(hotkey2)
seperator = _SEPERATORS[string.lower(seperator or '')] or
seperator or ''
return '<b>' .. hotkey1 .. seperator .. hotkey2 .. '</b>'
end
return Class.export(Hotkeys, {frameOnly = true})