Some significant whitespace is inserted in "xmlWhitespaceSensitivity: ignore" mode
See original GitHub issueAssume the following xml file:
<test>
<field name="report_name">event_third_party.template_event_third_party_summary</field>
<field name="report_file">event_third_party.template_event_third_party_summary</field>
</test>
In xmlWhitespaceSensitivity: ignore
mode, signficant whitespace is sometimes inserted to cut long lines, so we get:
<test>
<field name="report_name">
event_third_party.template_event_third_party_summary
</field>
<field name="report_file">
event_third_party.template_event_third_party_summary
</field>
</test>
For our application, the inserted space in field
elements is significant.
In strict
mode the issue does not occur, but then most automatic indenting is disabled.
My feeling is that, in ignore
mode, the text content of an element should never be modified as soon as there is a non-whitespace character in it.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Not formatting my xml, don't see a trace of the plugin being ...
Using VS Code in WSL mode, prettier and @prettier/plugin-xml installed ... If you want to ignore whitespace sensitivity, you should use the ...
Read more >UNPKG - @prettier/plugin-xml
- Better idempotency when printing long strings of text content within elements with ignored whitespace. 26. 27, ## [2.0.0] ...
Read more >@prettier/plugin-xml | Yarn - Package Manager
If you're sure that the XML files that you're formatting do not require whitespace sensitivity, you can use the "ignore" option, as this...
Read more >What You Need to Know About Whitespace in XML - Oracle
Learn about the concept of XML whitespace, and gets tips for avoiding ... Significant whitespace is part of the document content and should...
Read more >@prettier/plugin-xml - npm Package Health Analysis | Snyk
Security and license risk for significant versions ... xmlWhitespaceSensitivity, --xml-whitespace-sensitivity, "strict", Options are "strict" and "ignore" .
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@kddeisz there must be a misunderstanding.
I totally agree that determining if a node containing only white space is significant or not requires
xml:space
(and possibly access to the schema to obtain its value, which is out of scope for this tool).That is not what I am asking for.
To clarify, I found a nice description of different types of white space in XML at https://www.liquid-technologies.com/XML/Whitespace.aspx, and I copy the relevant picture here for clarity.
What prettier/plugin-xml needs is a mode where it allows itself to reformat red and blue white space, while never modifying green whitespace.
I don’t know if/when I’ll be able to do a PR. In the meantime could we reopen the issue to track this enhancement request ?
What do you recommend: updating the behavior of
xmlWhitespaceSensitiveity=ignore/strict
or add a third option ?