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.

Crushing html produces unwanted "empty lines filled with whitespaces"

See original GitHub issue

Package’s name html-crush (4.1.4)

Describe the situation Here is a Simple example to reproduce my problem. It should be self explanetory 😃

const { crush } = require("html-crush")

const input = `<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div>Hello</div>
</body>
</html>
`

const output = crush(input, {
  removeLineBreaks: true,
  removeIndentations: true,
  removeHTMLComments: true,
  removeCSSComments: true,
})

output.result === `<!DOCTYPE html>

<html lang="en">

<head>
  
<meta charset="UTF-8">
  
<meta http-equiv="X-UA-Compatible" content="IE=edge">
  
<meta name="viewport" content="width=device-width, initial-scale=1.0">
  
<title>Document</title>

</head>

<body><div>Hello</div>

</body>

</html>
`

Is there something I’m doing wrong?

I would like the result to be compacted with no extra newlines/whitespaces, until the line length is reached…

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
reveltcommented, Apr 3, 2021

It should be fixed in 4.1.7 released an hour ago, please confirm

1reaction
reveltcommented, Apr 1, 2021

I think I found the source, the CJS build, during Rollup+Babel somehow omits the spread operator which changes the logic of the program. However, the ESM and UMD builds are fine! That threw me off track at the beginning… Only CJS, CommonJS builds are not working as intended. What’s crazy is that it’s a real bug somewhere in Babel, or rather its config… I’ll nail this very soon.

@SylannBin, thank you for flagging this up! I’ll write up an article what went wrong and publish and credit you for the find.

Again, sorry for the bug.

It’s a shitty situation, I did all my best, unit tests passed (on ESM), it’s just Babel and/or Rollup produced a bad output which they should not have produced. But I’m “responsible” for the library in the end… Do you see? The bundlers should not even allow broken code, they should be smart-enough to alert us! Anyhow, I plan to release a patch this weekend.

Sorry about this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to remove empty lines with or without whitespace in Python
I have large string which I split by newlines. How can I remove all lines that are empty, (whitespace ...
Read more >
Controlling Whitespace and Empty Lines in Jekyll - Josh Dick
The empty lines are undesirable since they are unnecessary and they make the generated output uglier. The Solution. Here's my solution for ...
Read more >
Configure editor to remove whitespaces in blank lines
Is it possible to configure an editor in pycharm to automatically remove whitespaces in blank lines and trailing whitespaces when saving...
Read more >
Remove Empty Lines & Extra Spaces from Document Easily
How can we remove all empty extra lines from the code? ... this one matches new line character In short Remove lines that...
Read more >
[QUES] Remove multiple white spaces and empty lines in a ...
My target is : To remove all unnecessary white spaces (Not between two words of a sentence) and to arrange them in their...
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