Changeset

11642:7f2dee4249aa

util.stanza: Export pretty printing function
author Kim Alvefur <zash@zash.se>
date Tue, 29 Jun 2021 16:06:54 +0200
parents 11641:b03053ec6dcf
children 11643:f534eeee1552
files teal-src/util/stanza.d.tl util/stanza.lua
diffstat 2 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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;
 };