1,986
edits
No edit summary |
(Implement image alts) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
function p.main(frame) | function p.main(frame) | ||
local | local inp = frame.args[1] | ||
local | local beginspan = "<span class='nowrap'>" | ||
local | local size = "20px" | ||
if (frame.args[2]) | if (frame.args[2] and not(frame.args[2] == "")) | ||
then | then | ||
beginspan = "<span class='nowrap' title='" .. frame.args[2] .. "'>" | |||
end | end | ||
if (frame.args[3]) | if (frame.args[3] and not(frame.args[3] == "")) | ||
then | then | ||
size = frame.args[3] | |||
end | end | ||
if (mw.ustring.match( | if (mw.ustring.match(inp, "[A-z0-9-]")) | ||
then | then | ||
return " | return beginspan .. "[[File:Twemoji12 " .. inp .. ".svg|".. size .."|link=|alt=]]</span>" | ||
else | else | ||
local cps = {} | local cps = {} | ||
local i = 1 | local i = 1 | ||
for codepoint in mw.ustring.gcodepoint( | for codepoint in mw.ustring.gcodepoint(inp) do | ||
cps[i] = string.format("%x", codepoint) | cps[i] = string.format("%x", codepoint) | ||
i = i + 1 | i = i + 1 | ||
Line 32: | Line 32: | ||
local output = table.concat(cps, "-") | local output = table.concat(cps, "-") | ||
return " | return beginspan .. "[[File:Twemoji12 " .. output .. ".svg|".. size .."|link=|alt=" .. inp .. "]]</span>" | ||
end | end | ||
end | end | ||
return p | return p |