Module:ColorParse: Difference between revisions

933 bytes added ,  22:55, 8 August 2019
m
no edit summary
(allowed a second argument: if 'no linebreak parse' it will not replace all new line with html <br>s)
mNo edit summary
Line 69: Line 69:
     end)
     end)
return b
return b
end
function p.moduleparse(frame)
local b = string.gsub(frame,"([{}])", "")
local b = string.gsub(b,"(~J211)", "")
local a = string.gsub(b,"(&amp;)(%w)([^&\n]*)", function(_,color,text)
        local luatable = {
            ['r'] = "#a64a2e",
            ['R'] = "#d74200",
            ['g'] = "#009403",
            ['G'] = "#00c420",
            ['b'] = "#0048bd",
            ['B'] = "#0096ff",
            ['c'] = "#40a4b9",
            ['C'] = "#77bfcf",
            ['m'] = "#b154cf",
            ['M'] = "#da5bd6",
            ['w'] = "#98875f",
            ['W'] = "#cfc041",
            ['k'] = "#0f3b3a",
            ['K'] = "#155352",
            ['y'] = "#b1c9c3",
            ['Y'] = "#FFFFFF",
            ['o'] = "#f15f22",
            ['O'] = "#e99f10"
        }
        return "<span style=\"color: " .. luatable[color] .. ";\">"  .. text .. "</span>"
    end)
local c
c = string.gsub(a,"(\n)", "</br>")
return c
end
end


return p
return p