Module:ColorParse: Difference between revisions
Jump to navigation
Jump to search
(fixed bug with colored spaces not showing up properly) |
(put space back in span style) |
||
Line 46: | Line 46: | ||
regextype = regextype or '' | regextype = regextype or '' | ||
--[Determine regex type] | --[Determine regex type] | ||
local regex = "(&)(%w | local regex = "(&)(%w)([^&\n]*)" | ||
if regextype == 'notxml' then | if regextype == 'notxml' then | ||
regex = "(&)(%w | regex = "(&)(%w)([^&\n]*)" | ||
end | end | ||
local b = normalize(frame.args[1],regextype) | local b = normalize(frame.args[1],regextype) | ||
local a = string.gsub(b, regex, function(_,color | local a = string.gsub(b, regex, function(_,color,text) | ||
if text ~= nil or text ~= "" then | |||
local hexcolor = luatable[color] | local hexcolor = luatable[color] | ||
if hexcolor == nil then | if hexcolor == nil then | ||
Line 60: | Line 59: | ||
end | end | ||
text = text or "" | text = text or "" | ||
return | return "<span style=\"color: " .. hexcolor .. ";\">" .. text .. "</span>" | ||
else | |||
return | return "" | ||
end | |||
end) | end) | ||
return a | return a |