diff --git a/lib/consolecolor.nom b/lib/consolecolor.nom index ba40bda..f4c4df9 100644 --- a/lib/consolecolor.nom +++ b/lib/consolecolor.nom @@ -13,10 +13,10 @@ test: "on magenta":45, "on cyan":46, "on white":47 for %name = %colornum in %colors: - with {%escapecode:"\027[\(%colornum)m"}: - run "\ - ..compile [\%name] to (..) - Lua value (quote \(quote %escapecode)) - compile [\%name %text] to (..) - Lua value "\\ - ..(\\(quote \(quote %escapecode))..\\(%text as lua expr).."\\27[0m")"" + %colornum = "\%colornum" + (=lua "COMPILE_ACTIONS").%name = (..) + [%nomsu, %tree] -> (..) + Lua value "'\\027[\(%colornum)m'" + (=lua "COMPILE_ACTIONS")."\%name 1" = (..) + [%nomsu, %tree, %text] -> (..) + Lua value "('\\027[\(%colornum)m'..\(%text as lua expr)..'\\027[0m')" diff --git a/string2.lua b/string2.lua index 034c751..5995de2 100644 --- a/string2.lua +++ b/string2.lua @@ -134,7 +134,7 @@ local string2 = { if match(str, "^_*[abdefgilnortuw][aefhilnoru][acdefiklnoprstu]*$") then for _index_0 = 1, #lua_keywords do local kw = lua_keywords[_index_0] - if match(str, ("^_*" .. kw)) then + if match(str, ("^_*" .. kw .. "$")) then str = "_" .. str end end @@ -145,7 +145,7 @@ local string2 = { if match(str, "^_+[abdefgilnortuw][aefhilnoru][acdefiklnoprstu]*$") then for _index_0 = 1, #lua_keywords do local kw = lua_keywords[_index_0] - if match(str, ("^_+" .. kw)) then + if match(str, ("^_+" .. kw .. "$")) then str = str:sub(2, -1) end end diff --git a/string2.moon b/string2.moon index 27e7122..2259272 100644 --- a/string2.moon +++ b/string2.moon @@ -67,7 +67,7 @@ string2 = { -- This pattern is guaranteed to match all keywords, but also matches some other stuff. if match str, "^_*[abdefgilnortuw][aefhilnoru][acdefiklnoprstu]*$" for kw in *lua_keywords - if match str, ("^_*"..kw) + if match str, ("^_*"..kw.."$") str = "_"..str return str @@ -77,7 +77,7 @@ string2 = { -- This pattern is guaranteed to match all keywords, but also matches some other stuff. if match str, "^_+[abdefgilnortuw][aefhilnoru][acdefiklnoprstu]*$" for kw in *lua_keywords - if match str, ("^_+"..kw) + if match str, ("^_+"..kw.."$") str = str\sub(2,-1) str = gsub(str, "^_(_*%d.*)", "%1") str = gsub(str, "_", " ")