X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=util%2Ftermcolours.lua;fp=util%2Ftermcolours.lua;h=dcdc994d0e98335f513de7b1abd8e22f003b95c0;hb=c42c29dffc9e531c563a9365c0d8de5f82cd9699;hp=a0fee7ce56cc1090bd7a9d1c9818a4c5baed3813;hpb=2e064754862a27e75a10fa0029ef90d908d4afec;p=prosody.git diff --git a/util/termcolours.lua b/util/termcolours.lua index a0fee7ce..dcdc994d 100644 --- a/util/termcolours.lua +++ b/util/termcolours.lua @@ -15,6 +15,9 @@ local tonumber = tonumber; local ipairs = ipairs; local io_write = io.write; local m_floor = math.floor; +local type = type; +local setmetatable = setmetatable; +local pairs = pairs; local windows; if os.getenv("WINDIR") then @@ -76,8 +79,10 @@ local function hex2rgb(hex) end setmetatable(stylemap, { __index = function(_, style) - local g = style:sub(7) == " background" and "48;5;" or "38;5;"; - return g .. color(hex2rgb(style)); + if type(style) == "string" and style:find("%x%x%x%x%x%x") == 1 then + local g = style:sub(7) == " background" and "48;5;" or "38;5;"; + return g .. color(hex2rgb(style)); + end end } ); local csscolors = {