-
Notifications
You must be signed in to change notification settings - Fork 82
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
Format CDATA sections without adding new lines #585
Comments
Please don't insert white space around
|
As a work around, disable formatting in the Redhat extension. And install this which will use xmllint to format.
|
Is there already information here if/when this could be fixed? |
No sorry we must redo our formatter to fix this kind of problem |
OK I started to implement from scratch a new formatter. I will take care of this issue. |
@JessicaJHee I think experimental formatter fix this issue? |
Thanks @JessicaJHee for your feedback. @jonsmirl @kapexx please install prerelease https://github.com/redhat-developer/vscode-xml#contributing to enjoy with this fix or wait for the release which will come soon. |
I work with XML documents that contain a lot CDATA sections. These are mostly used for content that has to contain some exact value and is sensitive to whitespace changes.
When I use the formatter to format the document, an element like this:
becomes this:
In many cases the added newlines are fine (e.g. if the content is canonicalized or if additional whitespace doesn't matter) but I have to send the document to a system that is very picky about whitespace and doesn't process the element correctly because of the additional newlines.
Another case (this one is fictional though) where this is an issue, is using CDATA for xs:enumeration values. For example, if we have an enumeration that allows values like "<" and ">":
is valid, but when formatting it becomes invalid:
which results in an error:
Of course for these small examples, using entities instead CDATA would work. In other cases that's not always feasible though. Is there an option to avoid adding newlines around CDATA sections? I think at least for the second example, where formatting breaks the document, an option like that would be justified.
The text was updated successfully, but these errors were encountered: