question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

non-breaking spaces are being rewritten to spaces

See original GitHub issue

When using collapseWhitespace:true and conservativeCollapse:true options, I’m seeing that non-breaking spaces (character code 160, represented as \u00A0 below) are being incorrectly converted to regular spaces (character code 32). This isn’t expected and can alter the presentation of the html - especially when the html is sent in an email. Some email clients such as gmail will collapse paragraphs with regular spaces.

$ node
> require('html-minifier').minify('<p>\u00A0</p>').charCodeAt(3)
160 // This is correct - a non-breaking space.
> require('html-minifier').minify('<p>\u00A0</p>',{collapseWhitespace:true, conservativeCollapse: true}).charCodeAt(3)
32 // This should be 160, a non-breaking space. Instead it's a regular space.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:9

github_iconTop GitHub Comments

2reactions
jacksonpcommented, Feb 19, 2017

3.3.2 fixes it. Nice one, thanks.

1reaction
alexlamslcommented, Feb 8, 2017

Thanks for the report - fixing via #780.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Preventing the Insertion of Non-Breaking Spaces
If you want to get rid of non-breaking spaces already in the document, then using Find and Replace is the easiest way: Press...
Read more >
How to Insert Nonbreaking Spaces in Microsoft Word
1. Place your cursor where the nonbreaking space should be inserted. · 2. Select the Insert tab. · 3. Select Symbols in the...
Read more >
Topic: Non-breaking spaces appearing as extra-wide spaces
I've written before about a challenge I'm experiencing where non-breaking spaces are being inserted (rather than regular spaces) in my posts ...
Read more >
Non-breaking space - Wikipedia
In word processing and digital typesetting, a non-breaking space, , also called NBSP, required space, hard space, or fixed space is a space...
Read more >
Non breaking space - Microsoft Community
I want to prevent the automatic insertion of non-breaking spaces. I'm happy to use them when I want them but not when Word...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found