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.

Newline inserted at end of <script> or <style> when `end_with_newline` enabled

See original GitHub issue

js-beautify always inserts a newline at the end of a <script> or <style> block, and I can’t find an option to turn this behavior off.

Before:

<style type="text/css">
    body {
        display: none;
    }
</style>

<script type="text/javascript">
    (function() {
        console.log("Hello, World");
    })();
</script>

After:

<style type="text/css">
    body {
        display: none;
    }

</style>

<script type="text/javascript">
    (function() {
        console.log("Hello, World");
    })();

</script>

If there is a newline at the start of the tag, it deletes it as well:

Before:

<style type="text/css">

    body {
        display: none;
    }
</style>

<script type="text/javascript">

    (function() {
        console.log("Hello, World");
    })();
</script>

After:

<style type="text/css">
    body {
        display: none;
    }

</style>

<script type="text/javascript">
    (function() {
        console.log("Hello, World");
    })();

</script>

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
MacKLesscommented, Aug 22, 2018

This has been addressed and resolved (with tests) when I checked using v1.8.0-rc12. See the Readme (https://github.com/beautify-web/js-beautify#setting-inheritance-and-language-specific-overrides) for more information. This is also the case for Issue #639.

0reactions
eliashdezrcommented, Nov 30, 2016

Any news on this? I’m facing the same issue. This is a little annoying when working with Vue, where you have the script and style tags on the same file.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why should text files end with a newline? - Stack Overflow
If content is added to the end of the file, then the line that was previously the last line will have been edited...
Read more >
How to disable vscode auto format adding newline at EOF
VS versions: config.json: { "workbench.colorTheme": "Monokai", "editor.fontSize": 16, "editor.formatOnPaste": true, // Format a file on save ...
Read more >
Should I end my text/script files with a newline? [duplicate]
An empty line at the end means that the file ends in two newline characters. If the file ends with a single newline...
Read more >
On save new line added to end of file. How stop this?
When I save a file, PhpStorm adds a new line to the end of the file. ... You either enable it or disable...
Read more >
js-beautify - npm
The beautifier can be added on your page as web library. ... --end-with-newline End output with newline -b, --brace-style [collapse|expand] ...
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