Js-beautify: Preserve attributes line break in HTML

Created on 26 Apr 2014  ·  23Comments  ·  Source: beautify-web/js-beautify

like this

  <div id="anId"
       name="aName"
       class="aClass"
       onclick="alert('hello')"
       ondblclick="alert('hello')">asdf</div>

  <input type="text"
         name="aName"
         class="aClass"
         id="anId">
html enhancement

Most helpful comment

So wrap_attributes=auto doesn't seem to do anything. What's the expected behavior? The code doesn't seem to do anything with that setting.

wrap_attributes=force does not completely address OP's issue. With this convention the indentation should be based on the position of the first attribute, not based on a fixed width. Maybe I'll make this a new issue.

EDIT: I see there are already some issues for this request, I'll update it.

All 23 comments

Please describe current output so we can see how it differs.

it will just concatenate into one line

  <div id="anId" name="aName" class="aClass" onclick="alert('hello')" ondblclick="alert('hello')">asdf</div>

  <input type="text" name="aName" class="aClass" id="anId">

could we have one more option to preserve line break of html attributes or line break within the angle bracket, plus auto align the first character of each attributes?

Would like to see this too...

This would be pretty awesome :+1:

+1

+1

+1

Good to know folks. Anyone want to take a swing at a PR?

+1

+1

+1

+1

@jfletcher-nuxeo, @websirnik , @frasator , @kentliau ,
I believe this is fixed in 1.6.0. Please take a look at the wrap_attributes settings.

So wrap_attributes=auto doesn't seem to do anything. What's the expected behavior? The code doesn't seem to do anything with that setting.

wrap_attributes=force does not completely address OP's issue. With this convention the indentation should be based on the position of the first attribute, not based on a fixed width. Maybe I'll make this a new issue.

EDIT: I see there are already some issues for this request, I'll update it.

agreed with @jfletcher-nuxeo , better to position by first attribute

+1 to align with first attribute in the actual html element.

+1

+1

did anyone solve this issue?

@jorgeramirez - See #1015. Does wrap_attributes = "force-aligned" work for you?

Any news on this issue? its quite annoying!

@Vortilion
This issue is closed fixed. What's your question? Please join us on Gitter if you want to chat.

Where can I do this? As far as I can see it here it’s not fixed? This option does nothing for me... it always formats the html attributes as one liner...ö

Was this page helpful?
0 / 5 - 0 ratings