vscode-blade-formatter icon indicating copy to clipboard operation
vscode-blade-formatter copied to clipboard

Request to support additional HTML formatting options

Open yehudabrick opened this issue 3 years ago • 2 comments

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.

yehudabrick avatar Sep 15 '22 08:09 yehudabrick

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.

shufo avatar Sep 16 '22 01:09 shufo

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.

yehudabrick avatar Sep 16 '22 04:09 yehudabrick

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

github-actions[bot] avatar Nov 16 '22 02:11 github-actions[bot]

Prettier formatting would be nice

ojvribeiro avatar Dec 30 '22 14:12 ojvribeiro

Also requesting this option please. The empty lines are really irritating.

majorregal avatar Jan 17 '23 08:01 majorregal

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

github-actions[bot] avatar Mar 19 '23 02:03 github-actions[bot]

Bump

ojvribeiro avatar Mar 19 '23 04:03 ojvribeiro

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

github-actions[bot] avatar May 19 '23 01:05 github-actions[bot]

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

github-actions[bot] avatar Oct 11 '23 01:10 github-actions[bot]

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

github-actions[bot] avatar Dec 12 '23 01:12 github-actions[bot]

Sorry I forgot notifying. This feature was introduced since https://github.com/shufo/vscode-blade-formatter/releases/tag/v0.22.0

shufo avatar Dec 31 '23 11:12 shufo