plugin-xml icon indicating copy to clipboard operation
plugin-xml copied to clipboard

Whitespace is incorrectly preserved when `xmlWhitespaceSensitivity` is set to `ignore`

Open Comandeer opened this issue 1 year ago • 0 comments

According to the XML specification, only \t, \n, \r, and (space character) are considered whitespace and are affected by the xml:space attribute. As it has been already raised in #768, the plugin used String#trim() to remove whitespace characters, affecting also other non-XML whitespace characters:

This issue has been fixed in 6170e95. However, the fix still affects most of the characters mentioned above due to the usage of the \s character class and the issue described originally in #768 still persists.

Probably the easiest way to fix the issue is to replace the \s character class with the (space character):

const content = chardata.TEXT.replaceAll(/^[\t\n\r ]+|[\t\n\r ]+$/g, "");

Comandeer avatar May 28 '24 13:05 Comandeer