-
-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Some significant whitespace is inserted in "xmlWhitespaceSensitivity: ignore" mode #138
Comments
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 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 |
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: <test>
<!-- prettier-ignore-start -->
<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>
<!-- prettier-ignore-end -->
</test> As a side note, do you have a published XSD schema somewhere where you have the whitespace rules listed? Or maybe a |
@kddeisz there must be a misunderstanding. I totally agree that determining if a node containing only white space is significant or not requires 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. |
@kddeisz would you reconsider, given my previous comment ? |
Sure! If you want to open a PR I’d be happy to take a look.
On Tue, Jan 26, 2021 at 4:46 AM Stéphane Bidoul ***@***.***> wrote:
@kddeisz <https://github.com/kddeisz> would you reconsider, given my
previous comment ?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#138 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABG3P3UP2FQ4YI3GRP45SMLS32FPRANCNFSM4TGQAUOA>
.
--
*Kevin D. Deisz*
Staff Production Engineer
Shopify <https://www.shopify.com/>
|
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 |
…not break data Files are prettier when formatted with the 'ignore' mode, but it breaks Odoo/Python data by introducing significant whitespace. See prettier/plugin-xml#138
…not break data Files are prettier when formatted with the 'ignore' mode, but it breaks Odoo/Python data by introducing significant whitespace. See prettier/plugin-xml#138
Assume the following xml file:
In
xmlWhitespaceSensitivity: ignore
mode, signficant whitespace is sometimes inserted to cut long lines, so we get: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.The text was updated successfully, but these errors were encountered: