-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Unexpected formatting for script tag #6393
Copy link
Copy link
Labels
lang:htmlIssues affecting HTML (and SVG but not JSX)Issues affecting HTML (and SVG but not JSX)locked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.
Metadata
Metadata
Assignees
Labels
lang:htmlIssues affecting HTML (and SVG but not JSX)Issues affecting HTML (and SVG but not JSX)locked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.
Prettier 1.18.2
Playground link
Input:
Output:
Expected behavior:
There are several previous GH issues about HTML whitespacing sensitivity, which seem to be related to this but not quite the same. There's also https://prettier.io/blog/2018/11/07/1.15.0.html#whitespace-sensitive-formatting.
For the above input, the output for
cssandstrictare the same. For this case, prettier adds an extra newline for</script><script></script>, and borrows the closing>while doing so.This looks like an incorrect result. I expected either
<script></script>on a newline (without the borrowed>), or for the input HTML to remain unmodified (when usingstrict).This output is also problematic for syntax highlighters. You can see this happening in Github's highlighting for the text above.