Atom-beautify: html comment new line after beautify

Created on 10 Oct 2017  路  11Comments  路  Source: Glavin001/atom-beautify

Description

The results of beautification are not what I expect.

Input Before Beautification

This is what the code looked like before:

  <div class="container">
        <div class="row">
          <div class="col-md-4">

          </div><!--/col-->
          <div class="col-md-8">

          </div><!--/col-->
        </div><!--row-->
    </div><!--container-->>

Expected Output

The beautified code should have looked like this:

 <div class="container">
        <div class="row">
          <div class="col-md-4">

          </div><!--/col-->
          <div class="col-md-8">

          </div><!--/col-->
        </div><!--row-->
    </div><!--container-->

Actual Output

The beautified code actually looked like this:

    <div class="container">
      <div class="row">
        <div class="col-md-4">

        </div>
        <!--/col-->
        <div class="col-md-8">

        </div>
        <!--/col-->
      </div>
      <!--row-->
    </div>
    <!--container-->

Hi,
As you can see after I beautify the code, the html comments next to the html tags go to a new line and that makes the code messy and also adds unnecessary lines and makes the code larger. Is there any way to change this property?
Thanks

stale

All 11 comments

Which beautifier was used? It was likely JS Beautify or Pretty Diff. If you generate the debug.md file you can see which one is used.

With both JS Beautify and Pretty Diff happens the same. Can I configure this?

There was a really old issue I closed yesterday about this. Normally the beautifiers are smart enough to know that a line comment following some code on the same line is related specifically to the code on that line. The exception here (and thus challenge) is that the comment is following an end tag. It is hard to know that the comment is directly related to that previous tag, since an end tag closes a structure, or if it is comment between this structure and the next and just happens to be written on this line out of convenience.

So, There isn't anything we can do at this moment?

If you can provide some design direction to us know when a comment should be paired with a preceding end tag versus when it shouldn't I can implement the solution.

Well, I think it should stay in the same line after all the ending tags, and if someone wants it in a new line that's what preserve new lines property is for. That way is more decent.

Good point. I will investigate this.

Thanks I'll be waiting for your response

In the latest release of atom-beautify, using PrettyDiff when I have something like this:

<!--
`myelement-create-layout`
@group Nuxeo UI
@element myelement-create-layout
-->

It gets merged into a single line. Do you think this is related? Or should I open a new bug? FWIW I have "preserve newlines" enabled.

EDIT: nevermind, turns out the formatting is completely broken.

This issue has been automatically marked as stale because it has not had recent activity. If this is still an issue, please add a comment. It will be closed if no further activity occurs. Thank you for your contributions.

Still an issue, at least for Vue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

misterernest picture misterernest  路  3Comments

jasonivers picture jasonivers  路  4Comments

opikhidayat picture opikhidayat  路  4Comments

philippelesaux picture philippelesaux  路  4Comments

CorentinAndre picture CorentinAndre  路  4Comments