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

HTML format, no break after <label>? #1365

Closed
hstig opened this issue Apr 5, 2018 · 5 comments
Closed

HTML format, no break after <label>? #1365

hstig opened this issue Apr 5, 2018 · 5 comments

Comments

@hstig
Copy link

hstig commented Apr 5, 2018

Input

The code looked like this before beautification:

<div class="col-xs-2">
  <input type="radio" class="control-label" ng-disabled="!col" ng-model="col" value="2" class="form-control" id="coli" name="coli" />
  <label for="coli" class="control-label">Collision</label></div>


Expected Output

The code should have looked like this after beautification:

<div class="col-xs-2">
  <input type="radio" class="control-label" ng-disabled="!col" ng-model="col" value="2" class="form-control" id="coli" name="coli" />
  <label for="coli" class="control-label">Collision</label>
</div>

Actual Output

The code actually looked like this after beautification:

<div class="col-xs-2">
  <input type="radio" class="control-label" ng-disabled="!col" ng-model="col" value="2" class="form-control" id="coli" name="coli" />
  <label for="coli" class="control-label">Colision</label></div>

Steps to Reproduce

js-beautify --html -r -s 2 -b collapse

Environment

OS: debian etch
js-beautify 1.7.5

@MacKLess MacKLess added this to the v1.8.x milestone Aug 26, 2018
@bitwiseman bitwiseman modified the milestones: v1.9.x, v1.10.x Apr 29, 2019
@gabrielhfgomes
Copy link

gabrielhfgomes commented May 28, 2019

Is this bug solved? I got the same formatting problem!

@bitwiseman
Copy link
Member

@gabrielhfgomes
Nope, still there. Help welcome.

@gabrielhfgomes
Copy link

gabrielhfgomes commented May 28, 2019

I was having this problem with the embedded version of beautify in VSCode, I solved it now by rolling back the extension to a 2 year behind version, the 1.0.2 and than the formatting worked perfectly as expected. Maybe it was some removed code from this older version...

@bitwiseman
Copy link
Member

@gabrielhfgomes
Not impossible, the code from two years ago was completely different and probably didn't even test properly. Thanks for trying.

@bitwiseman
Copy link
Member

bitwiseman commented May 28, 2019

This line will cause tags like that </div> to be moved to a new line:
https://github.com/beautify-web/js-beautify/blob/master/js/src/html/beautifier.js#L706

However blocks like this are what set that flag:
https://github.com/beautify-web/js-beautify/blob/333710642f1fdf1fddd65ab8e7fe9ace483ca4c5/js/src/html/beautifier.js#L728-L733

That is obviously not getting set in some key scenarios. Basically, we need to detect newlines when not inside an element tag.

@bitwiseman bitwiseman mentioned this issue May 29, 2019
6 tasks
@bitwiseman bitwiseman modified the milestones: v1.10.x, v1.10.xx Jan 14, 2020
@bitwiseman bitwiseman modified the milestones: v1.10.x, v1.11.x Apr 5, 2020
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

4 participants