html-parse-stringify2
html-parse-stringify2 copied to clipboard
About text node
Thank you very much for providing such a good tool. I have encountered some problems during use. The problem may appear in this code:
// if a node is nothing but whitespace, collapse it as the spec states:
// https://www.w3.org/TR/html4/struct/text.html#h-9.1
if (/^\s*$/.test(content)) {
content = ' ';
}
Then I research the Spec and found this:
Note that a sequence of white spaces between words in the source document may result in an entirely different rendered inter-word spacing (except in the case of the PRE element). In particular, user agents should collapse input white space sequences when producing output inter-word space. This can and should be done even in the absence of language information (from the lang attribute, the HTTP "Content-Language" header field (see [RFC2616], section 14.12), user agent settings, etc.). The PRE element is used for preformatted text, where white space is significant.
Coincidentally, I am about to show multiple spaces in the pre element, but when using html-parse-stringify2
, it merges all the spaces into one. So if it possible to provide a configuration item for the user to choose whether or not to merge spaces?