Module:ColorParse: Difference between revisions

89 bytes added ,  18:01, 17 September 2019
if text is empty return just blank
m (standardized what linebreak to use)
(if text is empty return just blank)
Line 53: Line 53:
   local b = normalize(frame.args[1],regextype)
   local b = normalize(frame.args[1],regextype)
   local a = string.gsub(b, regex, function(_,color,space1,text)
   local a = string.gsub(b, regex, function(_,color,space1,text)
        if text ~=nil and text ~= '' then
         local hexcolor = luatable[color]
         local hexcolor = luatable[color]
         if hexcolor == nil then
         if hexcolor == nil then
Line 60: Line 61:
         text = text or ""
         text = text or ""
         return space1 .. "<span style=\"color: " .. hexcolor .. ";\">"  .. text .. "</span>"
         return space1 .. "<span style=\"color: " .. hexcolor .. ";\">"  .. text .. "</span>"
        else
          return ''
        end
   end)
   end)
return a
return a