Closed gaddlord closed 2 years ago
If whitespaces cannot be touched, there is little the pretty printer can do to make the XML look pretty.
You can protect parts of the document by providing a preserveWhitespace predicate. In your example you could tell the pretty printer not to touch the inside of the <test>
node:
document.toXmlString(
pretty: true,
preserveWhitespace: (node) => node is XmlElement && node.localName == 'test',
);
That did the trick. Yet I am still under the impression that Pretty Print should be used more as a Formatter of the XML document and not amend the Attribute/Elements text.
.toXmlString(pretty: true) converts \r\n in the text of elements to spaces. I believe this behavior is wrong - text inside elements should not be touched by prettification.
The test fails returning