Module:Twemoji: Difference between revisions

From Irony Wiki
Jump to navigation Jump to search
No edit summary
fuuuuuuuuuu
Line 20: Line 20:
if (mw.ustring.match(p1, "[A-z0-9-]"))
if (mw.ustring.match(p1, "[A-z0-9-]"))
then
then
return "{{inline emote|Twemoji12 " .. p1 .. ".svg|2=" .. p2 .. "|3=" .. p3 .. "}}"
-- return "{{inline emote|Twemoji12 " .. p1 .. ".svg|2=" .. p2 .. "|3=" .. p3 .. "}}"
return "[[File:Twemoji12 " .. p1 .. ".svg|20px|link=|alt=]]"
else
else
local cps = {}
local cps = {}
Line 32: Line 33:
local output = table.concat(cps, "-")
local output = table.concat(cps, "-")
return "{{inline emote|Twemoji12 " .. output .. ".svg|2=" .. p2 .. "|3=" .. p3 .. "}}"
--return "{{inline emote|Twemoji12 " .. output .. ".svg|2=" .. p2 .. "|3=" .. p3 .. "}}"
return "[[File:Twemoji12 " .. output .. ".svg|20px|link=|alt=]]"
end
end
end
end


return p
return p

Revision as of 06:44, 8 February 2021

Documentation for this module may be created at Module:Twemoji/doc

-- Implements Template:Twemoji

local p = {}

function p.main(frame)
	local p1 = frame.args[1]
	local p2 = ""
	local p3 = ""
	
	if (frame.args[2])
	then
		p2 = frame.args[2]
	end
	
	if (frame.args[3])
	then
		p3 = frame.args[3]
	end
	
	if (mw.ustring.match(p1, "[A-z0-9-]"))
	then
		-- return "{{inline emote|Twemoji12 " .. p1 .. ".svg|2=" .. p2 .. "|3=" .. p3 .. "}}"
		return "[[File:Twemoji12 " .. p1 .. ".svg|20px|link=|alt=]]"
	else
		local cps = {}
		local i = 1
		
		for codepoint in mw.ustring.gcodepoint(p1) do
			cps[i] = string.format("%x", codepoint)
			i = i + 1
		end
		
		local output = table.concat(cps, "-")
		
		--return "{{inline emote|Twemoji12 " .. output .. ".svg|2=" .. p2 .. "|3=" .. p3 .. "}}"
		return "[[File:Twemoji12 " .. output .. ".svg|20px|link=|alt=]]"
	end
end

return p