mirror of
https://github.com/kikito/inspect.lua.git
synced 2024-12-15 14:34:21 +00:00
tweaked string escaping, fixing GH-9
This commit is contained in:
parent
588486afde
commit
0303fec453
@ -34,7 +34,7 @@ local function smartQuote(str)
|
|||||||
if string.match( string.gsub(str,"[^'\"]",""), '^"+$' ) then
|
if string.match( string.gsub(str,"[^'\"]",""), '^"+$' ) then
|
||||||
return "'" .. str .. "'"
|
return "'" .. str .. "'"
|
||||||
end
|
end
|
||||||
return string.format("%q", str )
|
return string.format("%q", str ):gsub("\\\n", "\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
local controlCharsTranslation = {
|
local controlCharsTranslation = {
|
||||||
@ -268,7 +268,7 @@ function inspect.inspect(rootObject, options)
|
|||||||
local tv = type(v)
|
local tv = type(v)
|
||||||
|
|
||||||
if tv == 'string' then
|
if tv == 'string' then
|
||||||
puts(smartQuote(escape(v)))
|
puts(escape(smartQuote(v)))
|
||||||
elseif tv == 'number' or tv == 'boolean' or tv == 'nil' then
|
elseif tv == 'number' or tv == 'boolean' or tv == 'nil' then
|
||||||
puts(tostring(v))
|
puts(tostring(v))
|
||||||
elseif tv == 'table' then
|
elseif tv == 'table' then
|
||||||
|
Loading…
Reference in New Issue
Block a user