From 9488f30465bc0594ffa294025ab2d5522c736de4 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Fri, 1 Mar 2024 22:52:51 -0600 Subject: Refine string output --- pp.lua | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'pp.lua') diff --git a/pp.lua b/pp.lua index 3710b07..85d323e 100644 --- a/pp.lua +++ b/pp.lua @@ -1,6 +1,7 @@ --- lam.pp local pp = {} +table.unpack = table.unpack or unpack function pp.dump (x, lvl) lvl = lvl or 0 @@ -15,10 +16,12 @@ function pp.dump (x, lvl) v = pp.dump(v, lvl+2) end subo = subo .. string.format("\n%s[%s] = %s,", - (space.." "), k, v) + (space.." "), k, v) end output = output .. string.format("\n%s{%s\n%s}", - space, subo, space) + space, subo, space) + elseif type(x) == "string" then + output = output .. string.format("'%s'", x) else output = output .. string.format("%s", x) end @@ -30,7 +33,7 @@ function pp.pp (x) end return setmetatable(pp, { __call = - function(_, x) - return pp.pp(x) - end, + function(_, x) + return pp.pp(x) + end, }) -- cgit 1.4.1-21-gabe81