Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[ignoreWhitespace] are newlines equal to spaces?

Open
#150 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
css, javascript
Domain
testing

Research direction

Start with the code referenced at pull request #66, especially line 39 on the right, and reproduce the two HTML examples from the issue. Check how newline and space text nodes are compared; done means the examples are treated as equivalent without changing whitespace that CSS preserves.

Written by the indexing model from the issue text.

Description

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:

<p>A link. Not anymore.</p>

is not considered equal to

<p>A link.
Not anymore.</p>

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 not pre, pre-wrap, or pre-line, segment breaks (i.e. newlines) are usually converted to a space U+0020.

Dominant language
JavaScript
Stars
217
Forks
45
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bem/html-differ

All issues in bem/html-differ

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.