-
Notifications
You must be signed in to change notification settings - Fork 92
PrettyPrinter(minimizeEmpty = true) injects a new line into elements with attributes #231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hosam, Thanks for reporting this with an example. Indeed, it looks like the method Perhaps, there could be a check of |
Thanks, Aaron. I think that the conditional on line 160 may cause a different side effect. Specifically, I'm worried that an element with a long label and short attributes wouldn't be broken into multiple lines. To avoid this, I made a different change in PR #233 that should keep the behaviour of breaking the line in these cases. |
Ok, fair enough. Indeed, enforcing the width on attributes is a requirement. Did you see the nearby Thanks for the PR and including some minimal tests. |
Yes, I saw the |
Why reviewing the change, it was suggested that |
By definition, pretty-printing means injecting whitespaces around XML tags, changing the structure of the document. However, empty tags (i.e. ones without child nodes) are a special case. They should remain empty because the XML schema may not allow them to contain text. As such, the safest way to pretty-print them is to always make them self-closing. They can still be formatted, and the closing slash ( |
Fix #231: Minimize empty elements with lengthy attributes
Using scala-xml v1.1.0, pretty-printing a leaf node with attributes when
minimizeEmpty
is set to true injects a new line into the element:This behaviour renders the XML invalid if the schema dictates a non-mixed element.
The text was updated successfully, but these errors were encountered: