diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index d7e1b48b..ed73e5fb 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -453,6 +453,33 @@ const foo = [abc, def, ghi, jkl, mno, pqr, stu, vwx, yz] as ( )[]; ``` +#### HTML: Script tags are now treated as blocks for the purposes of formatting ([#6423] by [@thorn0]) + +Previously, in the [whitespace-sensitive mode](https://prettier.io/docs/en/options.html#html-whitespace-sensitivity), they were formatted as if they were inline. + + +```html + + + + + + + + + +``` + #### TypeScript: Fixed to break line and add a semicolon in one execution on one line long mapped types ([#6420] by [@sosukesuzuki]) Previously, when Prettier formatted long, one-line mapped types, it would break the line but didn’t add a semicolon – until you ran Prettier again (which broke Prettier’s idempotency rule). Now, Prettier adds the semicolon in the first run, fixing the issue. @@ -519,6 +546,7 @@ class Class { [#6307]: https://github.com/prettier/prettier/pull/6307 [#6340]: https://github.com/prettier/prettier/pull/6340 [#6412]: https://github.com/prettier/prettier/pull/6412 +[#6423]: https://github.com/prettier/prettier/pull/6423 [#6420]: https://github.com/prettier/prettier/pull/6420 [#6411]: https://github.com/prettier/prettier/pull/6411 [@duailibe]: https://github.com/duailibe @@ -527,3 +555,4 @@ class Class { [@g-harel]: https://github.com/g-harel [@jounqin]: https://github.com/JounQin [@bakkot]: https://gibhub.com/bakkot +[@thorn0]: https://github.com/thorn0 diff --git a/src/language-html/constants.evaluate.js b/src/language-html/constants.evaluate.js index 2ce6efaf..0ef1d89d 100644 --- a/src/language-html/constants.evaluate.js +++ b/src/language-html/constants.evaluate.js @@ -25,6 +25,7 @@ const CSS_DISPLAY_TAGS = Object.assign({}, getCssStyleTags("display"), { template: "inline", source: "block", track: "block", + script: "block", // there's no css display for these elements but they behave these ways video: "inline-block", diff --git a/tests/html_script/__snapshots__/jsfmt.spec.js.snap b/tests/html_script/__snapshots__/jsfmt.spec.js.snap index 168cd059..cb08b08c 100644 --- a/tests/html_script/__snapshots__/jsfmt.spec.js.snap +++ b/tests/html_script/__snapshots__/jsfmt.spec.js.snap @@ -17,11 +17,16 @@ printWidth: 80 - + + =====================================output===================================== + + + ================================================================================ `; diff --git a/tests/html_script/script.html b/tests/html_script/script.html index 58ef1529..580ac173 100644 --- a/tests/html_script/script.html +++ b/tests/html_script/script.html @@ -9,7 +9,12 @@ - + +