Module:Apitag

From Warcraft Watch Secrets
Revision as of 04:24, 31 December 2023 by imported>Ketho
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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

-- https://wowpedia.fandom.com/wiki/Template:Apitag
local m = {}

-- https://stackoverflow.com/a/7615129/1297035
local function strsplit(input, sep)
	local t = {}
	for s in string.gmatch(input, "([^"..sep.."]+)") do
		table.insert(t, s)
	end
	return t
end

local function FormatTags(s)
	local tags = strsplit(s, ",")
	local t = {}
	for _, v in pairs(tags) do
		table.insert(t, string.format("<code><font color=#dda0dd>&#35;%s</font></code>", v))
	end
	return table.concat(t)
end

function m.main(f)
	return FormatTags(f.args[1])
end

return m