Request to support additional HTML formatting options
Request to add a way to support html formatting features
<html>
<head>
@if ($condition->isTrue())
<div>
<p>We're ready</p>
</div>
@endif
</head>
<body>
<div>
<p></p>
<div></div>
</div>
</body>
</html>
When working with a template like the one above - the formatter removes the inner html element indentations (on the head and body tags). I would want it to stay formatted as it is above.
<html>
<head>
@if ($condition->isTrue())
<div>
<p>We're ready</p>
</div>
@endif
</head>
<body>
<div>
<p></p>
<div></div>
</div>
</body>
</html>
Like this.
Proposed solution
Right now, VS Code has built in settings for regular HTML formatting which would address the issues of the extra spacing around the html, head and body tags, as well as the removal of the indentation for them.
"html.format.indentInnerHtml": true,
"html.format.extraLiners": "head, body, /html",
I was thinking, maybe adding these two options to this plugin as well, and checking them when formatting the HTML would be a good solution.
Context
I'm not sure if it's relevant but I'm running the latest VS Code on macOS.
Thanks so much, as of now this is the best formatter for blade templates that I've found and really appreciate all the work that you put into it.
Hi @yehudabrick Thanks for suggesting the feature and solution.
To give some historical background, when I created this extension I considered how to indent the head and body tags, but js-beautify, which is used internally in this extension does not indent the head and body by default, so that is the behavior now.
I think that respecting the vscode setting you suggested is a good solution.
Or it might be a good to
- add a new settings for this behaviour
- indent by default like prettier's html formatter
Anyway, I'll try to do something about this behaviour. Thanks.
That sounds great, thank you for the quick response. Is there somewhere I can look to help create a pull request for implementing this? I'm not even sure if I should start here or in the underlying prettier plugin.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days
Prettier formatting would be nice
Also requesting this option please. The empty lines are really irritating.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days
Bump
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days
Sorry I forgot notifying. This feature was introduced since https://github.com/shufo/vscode-blade-formatter/releases/tag/v0.22.0