You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Some significant whitespace is inserted in "xmlWhitespaceSensitivity: ignore" mode #138
changed the title [-]In xmlWhitespaceSensitivity: ignore some significant whitespace is inserted[/-][+]Some significant whitespace is inserted in "xmlWhitespaceSensitivity: ignore" mode [/+]on Nov 1, 2020
Can you clarify what you mean by your last sentence? I'm not clear on what your suggested behavior would look like. Also could you give an example of what it would mean?
In other words, I think plugin-xml should have a mode where text nodes containing non-whitespace are never modified, while allowing reformating of whitespace-only text nodes. My impression is that this could be the behaviour of the xmlWhitespaceSensitiveity=ignore mode, but that could be another mode.
I don't think we can really make that option a reality. The issue is that it completely depends on the schema, which prettier at the moment has no way of understanding. Some users want some of these nodes modified and some not.
I think the best I can offer in this case is to make use of ignore ranges, as in:
As a side note, do you have a published XSD schema somewhere where you have the whitespace rules listed? Or maybe a xml:space attribute somewhere? I'm trying to figure out where I would be able to determine that something is whitespace-significant
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).
Activity
[-]In xmlWhitespaceSensitivity: ignore some significant whitespace is inserted[/-][+]Some significant whitespace is inserted in "xmlWhitespaceSensitivity: ignore" mode [/+]kddnewton commentedon Nov 1, 2020
Can you clarify what you mean by your last sentence? I'm not clear on what your suggested behavior would look like. Also could you give an example of what it would mean?
sbidoul commentedon Nov 1, 2020
In the example I gave, the result should look like this:
In other words, I think plugin-xml should have a mode where text nodes containing non-whitespace are never modified, while allowing reformating of whitespace-only text nodes. My impression is that this could be the behaviour of the
xmlWhitespaceSensitiveity=ignoremode, but that could be another mode.kddnewton commentedon Nov 9, 2020
I don't think we can really make that option a reality. The issue is that it completely depends on the schema, which prettier at the moment has no way of understanding. Some users want some of these nodes modified and some not.
I think the best I can offer in this case is to make use of ignore ranges, as in:
As a side note, do you have a published XSD schema somewhere where you have the whitespace rules listed? Or maybe a
xml:spaceattribute somewhere? I'm trying to figure out where I would be able to determine that something is whitespace-significantsbidoul commentedon Nov 10, 2020
@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.
sbidoul commentedon Jan 26, 2021
@kddeisz would you reconsider, given my previous comment ?
kddnewton commentedon Jan 26, 2021
sbidoul commentedon Jan 26, 2021
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/strictor add a third option ?[FIX] project template: put .prettierrc.yml in strict mode that does …
[FIX] project template: put .prettierrc.yml in strict mode that does …