renggli / dart-xml

Lightweight library for parsing, traversing, and transforming XML in Dart.
http://pub.dartlang.org/packages/xml
MIT License
223 stars 52 forks source link

Optionally add a space before auto-closing an element #125

Closed rspilker closed 2 years ago

rspilker commented 2 years ago

Adds a predicate parameter to the pretty printer to insert a space character before self-closing an element.

Fixes #109

renggli commented 2 years ago

Thank you, merged it into the main branch.

pihentagy commented 2 years ago

Shouldn't the default of spaceBeforeSelfClose be handled in the constructor, like all others? (level, indent and newLine)?

renggli commented 2 years ago

level, indent and newLine are literals. preserveWhitespace, indentAttribute, sortAttributes, spaceBeforeSelfClose are nullable functions. Their default behavior is inlined in the code.

pihentagy commented 2 years ago

level, indent and newLine are literals. preserveWhitespace, indentAttribute, sortAttributes, spaceBeforeSelfClose are nullable functions. Their default behavior is inlined in the code.

Thanks for clarifying. I thought it was just a simple parameter, that it adds a space for all self-closing tags.

But now the most common usage (when you'd like to just add spaces for all tags) is a bit complicated.