question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Some significant whitespace is inserted in "xmlWhitespaceSensitivity: ignore" mode

See original GitHub issue

Assume 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:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
sbidoulcommented, 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.

image

What prettier/plugin-xml needs is a mode where it allows itself to reformat red and blue white space, while never modifying green whitespace.

0reactions
sbidoulcommented, 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/strict or add a third option ?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found