-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ignoreWhitespace] are newlines equal to spaces? #150
Comments
Hi! Spaces are considered to be not equal to newline inside of html-tags... <p>
Hello, Bob!
</p> and <p>Hello, Bob!</p> are equal, but <p>Hello, Bob!</p> and <p>Hello,
Bob!</p> are not! If you need another behaviour, so you pull request some option, I think. |
Ah, now I see what went wrong there. <p>wrapped
paragraph</p>
<p>wrappedparagraph</p> HtmlDiffer = require('html-differ').HtmlDiffer;
htmlDiffer = new HtmlDiffer();
first = '<p>wrapped\nparagraph</p>';
second = '<p>wrappedparagraph</p>';
console.log(htmlDiffer.isEqual(first, second));
> true I think you should replace them with a space to adhere to the segment break transformation rules for non- <p>wrapped
paragraph</p>
<p>wrapped paragraph</p> which looks correct to me! |
I'd like to use html-differ to write a test system for marked, where generated html output is to be compared to pre-written html code, to determine if the two are equivalent, so I would like to ignore whitespace differences, when they are not meaningful (as in
<p>
tags), but I noticed that newlines are treated differently than spaces:is not considered equal to
when, IMO, they should be.
I've tracked this to be probably determined by this line of code (line 39 on the right).
I'm aware this issue is related to CSS, and not HTML itself. According to CSS specification, when the
white-space
property is notpre
,pre-wrap
, orpre-line
, segment breaks (i.e. newlines) are usually converted to a spaceU+0020
.The text was updated successfully, but these errors were encountered: