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.

Add an option to strip empty lines

See original GitHub issue

It would be useful if JS Beautify had an option to strip empty lines.

Includes, partials and other serverside code can create blank lines in the HTML. The HTML would be more beautiful without these blank lines.

This used to be the behaviour in version 1.3.1 but I think it was changed for https://github.com/einars/js-beautify/issues/285.

Input:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>Demo</title>
</head>
<body>
    <p>P1</p>

    <p>P2</p>

</body>
</html>

(Note: the line after P1 should contain some spaces and tabs but GitHub Flavored Markdown is removing them. This line should still be removed by JS Beautify.)

Configuration:

js-beautify input.html -o output.html --remove-empty-lines

Expected output:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>Demo</title>
</head>
<body>
    <p>P1</p>
    <p>P2</p>
</body>
</html>

Actual output:

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title>Demo</title>
</head>

<body>
    <p>P1</p>

    <p>P2</p>

</body>

</html>


Issue Analytics

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

github_iconTop GitHub Comments

2reactions
maciej-zukcommented, Jun 23, 2016

Hi, can you add same option for css?

1reaction
bitwisemancommented, Aug 29, 2013

Yeah, I see your point. Until we get to fixing this, have you tried 1 instead of 0? Does that exhibit the behavior you want?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Remove empty lines - Visual Studio Marketplace
Remove blank lines from document or selection. ... Launch VS Code Quick Open ( Ctrl+P ), paste the following command, and press enter....
Read more >
How to Remove Blank Lines from a File - Computer Hope
Open TextPad and the file you want to edit. · Click Search and then Replace. · In the Replace window, in the Find...
Read more >
How to remove empty lines in Visual Studio Code
Open your code in Visual Studio Code · From Edit Menu, select Replace or use a short cut key (command + Option +...
Read more >
Remove blank lines from text file - UltraEdit
This will delete all lines in the file that contain no characters or whitespace. If text is selected, then the operation is restricted...
Read more >
Adding or removing blank lines - IBM
Only the reverse of the currently active option is available from the View menu. That is, if Add Blank Lines is in effect,...
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