aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-06-29 16:06:54 +0200
committerKim Alvefur <zash@zash.se>2021-06-29 16:06:54 +0200
commitf40173b4c7d7e31d0264964de0999559c4f4e28f (patch)
treef96a4d07f5f37955885414c3359917f9e66e56d6
parent417846da58c448a45b5aba4e9a2d9d3b674c02dd (diff)
downloadprosody-f40173b4c7d7e31d0264964de0999559c4f4e28f.tar.gz
prosody-f40173b4c7d7e31d0264964de0999559c4f4e28f.zip
util.stanza: Export pretty printing function
-rw-r--r--teal-src/util/stanza.d.tl1
-rw-r--r--util/stanza.lua4
2 files changed, 4 insertions, 1 deletions
diff --git a/teal-src/util/stanza.d.tl b/teal-src/util/stanza.d.tl
index b96f9ff3..a358248a 100644
--- a/teal-src/util/stanza.d.tl
+++ b/teal-src/util/stanza.d.tl
@@ -56,6 +56,7 @@ local record lib
error_reply : function ( stanza_t, string, string, string, string )
presence : function ( { string : string } ) : stanza_t
xml_escape : function ( string ) : string
+ pretty_print : function ( string ) : string
end
return lib
diff --git a/util/stanza.lua b/util/stanza.lua
index 86ec458b..7f321da8 100644
--- a/util/stanza.lua
+++ b/util/stanza.lua
@@ -488,6 +488,7 @@ local function presence(attr)
return new_stanza("presence", attr);
end
+local pretty;
if do_pretty_printing then
local getstyle, getstring = termcolours.getstyle, termcolours.getstring;
@@ -512,7 +513,7 @@ if do_pretty_printing then
getstring(green1, "%3") -- ;
);
- local function pretty(s)
+ function pretty(s)
-- Tag soup color
-- Outer gsub call takes each <tag>, applies colour to the brackets, the
-- tag name, then applies one inner gsub call to colour the attributes and
@@ -581,4 +582,5 @@ return {
error_reply = error_reply;
presence = presence;
xml_escape = xml_escape;
+ pretty_print = pretty;
};