lovebird
lovebird copied to clipboard
Whitespaces are being trimmed
Currently it's almost impossible to use something like inspect.lua to inspect tables because there's no indentation. Probably trimmed when the text is being converted to HTML.
You can use <pre></pre>
tag. It doen't ignore spaces.
Yeah, but that would require
- output parsed as HTML, which is not always convenient
- extra code
- lovebird-specific print code if I don't want tags to show up in regular console
To expand on @egordorichev 's suggestion, you can paste the following into your code after you require()
lovebird. This will automatically wrap multi-line prints in <pre></pre>
and html-escape them:
lovebird.allowhtml = true
local oldprint = lovebird.print
lovebird.print = function(...)
local t = {}
for i = 1, select("#", ...) do
table.insert(t, tostring(select(i, ...)))
end
local str = table.concat(t, " ")
if str:find("\n") then
oldprint("<pre>" .. lovebird.htmlescape(str) .. "</pre>")
else
oldprint( (lovebird.htmlescape(str)) )
end
end
Much better, thanks!
You could also save the old lovebird.print
as lovebird.printhtml
, this way it's possible to use both HTML and text output.