Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty lines are removed in HTML and CSS, and also adds trailing spaces #285

Closed
manuq opened this issue Jun 8, 2013 · 6 comments
Closed

Comments

@manuq
Copy link

manuq commented Jun 8, 2013

Empty lines are good to organize code and for readability, but they are removed in HTML and CSS.

With HTML I also see that unwanted trailing spaces are added, and sometimes it does bad indentation.

Consider this HTML input processed with: js-beautify --type html --indent-size 2

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>Title</title>
  </head>
  <body>
    <div id="main-toolbar" class="toolbar">
      <button class="toolbutton" id="activity-button" title="My Activity"></button>

      <!-- Add more buttons here -->

      <!-- Buttons with class="pull-right" will be right aligned -->
      <button class="toolbutton pull-right" id="stop-button" title="Stop"></button>
    </div>

    <!-- The content of your activity goes inside the canvas -->
    <div id="canvas">

      <!-- Replace this message with your own content -->
      <h1>Header</h1>
      <p>Content text.</p>

    </div>
  </body>
</html>

The output is:

<!DOCTYPE html>
<html>

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

  <body>
    <div id="main-toolbar" class="toolbar">
      <button class="toolbutton" id="activity-button" title="My Activity"></button>
      <!-- Add more buttons here -->
      <!-- Buttons with class="pull-right" will be right aligned -->
      <button class="toolbutton pull-right" id="stop-button" title="Stop"></button>
    </div>
    <!-- The content of your activity goes inside the canvas -->
    <div id="canvas">
      <!-- Replace this message with your own content -->
       <h1>Header</h1>

      <p>Content text.</p>
    </div>
  </body>

</html>

The output has:

  • trailing spaces around the head tag
  • bad indentation in the h1 tag
  • all empy lines removed

I was expecting the output to be the same, as the input is correctly indented.

@bitwiseman
Copy link
Member

Using input you provided, the output as of a9f3d1a is almost correct.

The only remaining issue is bad indentation at the h1 tag.

<!DOCTYPE html>
<html>

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

  <body>
    <div id="main-toolbar" class="toolbar">
      <button class="toolbutton" id="activity-button" title="My Activity"></button>

      <!-- Add more buttons here -->

      <!-- Buttons with class="pull-right" will be right aligned -->
      <button class="toolbutton pull-right" id="stop-button" title="Stop"></button>
    </div>

    <!-- The content of your activity goes inside the canvas -->
    <div id="canvas">

      <!-- Replace this message with your own content -->
       <h1>Header</h1>
      <p>Content text.</p>

    </div>
  </body>

</html>

@manuq
Copy link
Author

manuq commented Jun 8, 2013

Ah, excellent! Do you want a new issue report or is fine tracking the indent issue here?

@bitwiseman
Copy link
Member

Leave this one, it's cool.

@keeganstreet
Copy link

I actually preferred when empty lines were removed. This is because my development environment uses partials and includes, which add their own new lines. I would like these to be stripped from the beautified HTML. Do you think it would be possible to add an option to strip empty lines?

@bitwiseman
Copy link
Member

Open a new issue for it, we'll look into it.

@keeganstreet
Copy link

OK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants