xml-formatter
xml-formatter copied to clipboard
Please make the default `lineSeparator` just '\n'
The current default is surprising, and causes problems when mixed with output from other programs which just use the standard line separator.
On a system that uses CRLF as its line separator, the caller of xml-formatter
should just output the formatted XML as text, not binary, and the system will automatically translate \n
to CRLF; there should be no need for a custom lineSeparator
for this use case.
Thanks for xml-formatter!
I'm afraid we might upset some people if we do that.
But there could be a compromise by using https://nodejs.org/api/os.html#os_os_eol to detect what should be used if the lineSeparator
option is missing but that would be a breaking change.
Why do you set the lineSeparator
option to \n
in your code?
I can believe that changing this default would cause some users problems, but it would be interesting to know in what circumstances.
Defaulting to the OS's EOL would be better, but it's still odd: why would you want an EOL rather than a newline other than when writing to a text stream?
I needed to set lineSeparator
because I am outputting the result of format()
to a text file on a system whose line ending is LF. Having the wrong line endings would be a problem in itself; in my case it was slightly worse because only part of the file's contents was the output of format()
.
Thanks for considering this!