Closed Sir-Will closed 4 years ago
Same for me. Everything else works perfectly, however this bug makes the extension unusable for me.
For now I added script
to this setting:
"html.format.contentUnformatted": "pre,code,textarea,script"
Duplicate of #31
@Sir-Will When reporting formatting issues, providing the actual text instead of an image helps people test fixes.
@RiFi2k @elitan @Sir-Will The reason for this is that, in jsbeautifier templating is turned on by default in HTML and turned off by default in JavaScript. This was done to limit the potential for breaking changes to existing users.
I suppose this default should be changed to on by default inside html <script>
tags, but that is longer term discussion.
The fix is to enble php
to the settings for jsbeautifier.
{
"html": {
"js": {
"templating": "php"
}
}
}
Filed #47 to fix this in this project.
Note: even when you do this, the above would still fail because jsbeautifier currently expects <?php
or <?=
to start PHP tags. I've opened https://github.com/beautify-web/js-beautify/issues/1840 to track fixing this. Any help would be much appreciated.
If you have php in a html
<script>
element then it breaks the formatting of it: