Module:ColorParse: Difference between revisions

79 bytes added ,  18:06, 26 July 2019
made ~ in parse represent a line break for multi possible dialogues. made not xml replace \n with a html br
(ColorParse has been upgraded to parse non xml files! (& escape char not used))
(made ~ in parse represent a line break for multi possible dialogues. made not xml replace \n with a html br)
Line 4: Line 4:
local b = string.gsub(frame.args[1],"([{}])", "")
local b = string.gsub(frame.args[1],"([{}])", "")
local b = string.gsub(b,"(~J211)", "")
local b = string.gsub(b,"(~J211)", "")
local b = string.gsub(b,"(~}","</br>")
local a = string.gsub(b,"(&amp;)(%w)([^&\n]*)", function(_,color,text)
local a = string.gsub(b,"(&amp;)(%w)([^&\n]*)", function(_,color,text)
         local luatable = {
         local luatable = {
Line 32: Line 33:


function p.nonxmlparse(frame)
function p.nonxmlparse(frame)
local a = string.gsub(frame.args[1],"(&)(%w)([^&\n]*)", function(_,color,text)
local a = string.gsub(frame.args[1],"(\n)","</br>")
local b = string.gsub(a,"(&)(%w)([^&\n]*)", function(_,color,text)
         local luatable = {
         local luatable = {
             ['r'] = "#a64a2e",
             ['r'] = "#a64a2e",
Line 56: Line 58:
         return "<span style=\"color: " .. luatable[color] .. ";\">"  .. text .. "</span>"
         return "<span style=\"color: " .. luatable[color] .. ";\">"  .. text .. "</span>"
     end)
     end)
return a
return b
end
end


return p
return p