Module:Color
Jump to navigation
Jump to search
local p = {}
local data = mw.loadData("Module:Color/Data")
function p.Main(frame)
local args = frame:getParent().args
return p.color(args[1], args[2])
end
function p.color(colorId, text)
local colorClass = string.lower(string.gsub(colorId, " ", "-"))
local html = mw.html.create("span")
:addClass("colored-text")
:addClass(colorClass)
:wikitext(text)
return tostring(html)
end
function p.dialogue(game, source, text)
local gameDialogueColors = data.dialogue[string.lower(game)] or {}
local color = gameDialogueColors[source] or gameDialogueColors.default
if color then
local colorId = game .. " " .. color
return p.color(colorId, text)
else
return text
end
end
return p