util.stanza: Export pretty printing function
authorKim Alvefur <zash@zash.se>
Tue, 29 Jun 2021 16:06:54 +0200
changeset 11646 7f2dee4249aa
parent 11645 b03053ec6dcf
child 11647 f534eeee1552
util.stanza: Export pretty printing function
teal-src/util/stanza.d.tl
util/stanza.lua
--- a/teal-src/util/stanza.d.tl	Tue Jun 29 16:05:35 2021 +0200
+++ b/teal-src/util/stanza.d.tl	Tue Jun 29 16:06:54 2021 +0200
@@ -56,6 +56,7 @@
 	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
--- a/util/stanza.lua	Tue Jun 29 16:05:35 2021 +0200
+++ b/util/stanza.lua	Tue Jun 29 16:06:54 2021 +0200
@@ -488,6 +488,7 @@
 	return new_stanza("presence", attr);
 end
 
+local pretty;
 if do_pretty_printing then
 	local getstyle, getstring = termcolours.getstyle, termcolours.getstring;
 
@@ -512,7 +513,7 @@
 		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 @@
 	error_reply = error_reply;
 	presence = presence;
 	xml_escape = xml_escape;
+	pretty_print = pretty;
 };