Mercurial > libervia-backend
comparison frontends/src/jp/output_xml.py @ 2192:577e19724744
jp (output xml): remove blank spaces on parsing for better pretty printing
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 13 Mar 2017 23:12:57 +0100 |
parents | d823a0cdbcc2 |
children | 8b37a62336c3 |
comparison
equal
deleted
inserted
replaced
2191:a1a8233f89e8 | 2192:577e19724744 |
---|---|
57 lexer = XmlLexer(encoding='utf-8') | 57 lexer = XmlLexer(encoding='utf-8') |
58 formatter = TerminalFormatter(bg=u'dark') | 58 formatter = TerminalFormatter(bg=u'dark') |
59 return pygments.highlight(xml, lexer, formatter) | 59 return pygments.highlight(xml, lexer, formatter) |
60 | 60 |
61 def format(self, data, pretty=True): | 61 def format(self, data, pretty=True): |
62 tree = etree.fromstring(data) | 62 parser = etree.XMLParser(remove_blank_text=True) |
63 tree = etree.fromstring(data, parser) | |
63 xml = etree.tostring(tree, encoding='unicode', pretty_print=pretty) | 64 xml = etree.tostring(tree, encoding='unicode', pretty_print=pretty) |
64 return self.colorize(xml) | 65 return self.colorize(xml) |
65 | 66 |
66 def format_no_pretty(self, data): | 67 def format_no_pretty(self, data): |
67 return self.format(data, pretty=False) | 68 return self.format(data, pretty=False) |