Skip to content

Inconsistent line break minification #262

Closed
@FranklinWhale

Description

@FranklinWhale

Description

The following XML document is handled properly by "Format Document" but not "XML Tools: Minify XML":

<tests>
<test>1.
2.
3.
4.</test>
<test xml:space="preserve">1.
2.
3.
4.</test>
<test>1.
 2.
 3.
 4.</test>
<test xml:space="preserve">1.
 2.
 3.
 4.</test>
</tests>

After "Format Document", the result is as follows, which is good:

<tests>
	<test>1.
2.
3.
4.</test>
	<test xml:space="preserve">1.
2.
3.
4.</test>
	<test>1.
 2.
 3.
 4.</test>
	<test xml:space="preserve">1.
 2.
 3.
 4.</test>
</tests>

However, with "XML Tools: Minify XML", text contents that have a whitespace before a EOL are normalized, which affects the meaning of those contents in whitespace sensitive applications:

<tests><test>1.
2.
3.
4.</test><test xml:space="preserve">1.
2.
3.
4.</test><test>1. 2. 3. 4.</test><test xml:space="preserve">1. 2. 3. 4.</test></tests>

The minifier should either stop text normalization when an ancestor element has xml:space="preserve" or change line breaks to &#x0D;, &#x0A; or &#x0D;&#x0A; depending on the EOL setting.

Formatter Implementation

v2

XML Tools Version

2.4.0

VS Code Version

1.31.1

Operating System

Windows 10 1809

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions