Prettier 2.6.2对HTML代码做出了奇怪的更改

发布于 2025-02-09 17:36:27 字数 692 浏览 0 评论 0原文

我是新来的。在运行Prettier之后,我在此HTML中有这种奇怪的现象:

<!DOCTYPE html>
<html>
  <head>
    <title>X</title>
  </head><!-- ddd --->
  <body></body>
</html>

然后我运行此命令:

prettier --write "./src/**/*.{ts,html,scss}"

结果是:

<!DOCTYPE html>
<html>
  <head>
    <title>X</title></head
  ><!-- ddd --->
  <body></body>
</html>

我有这个.prettierrc.json文件

{
"singleQuote": true,
"trailingComma": "es5",
"endOfLine": "auto",
"bracketSpacing": true,
"printWidth": 120
}

。谢谢。

I am new to prettier. I have this strange phenomena in this HTML, after running prettier:

<!DOCTYPE html>
<html>
  <head>
    <title>X</title>
  </head><!-- ddd --->
  <body></body>
</html>

Then i run this command:

prettier --write "./src/**/*.{ts,html,scss}"

And the result is this:

<!DOCTYPE html>
<html>
  <head>
    <title>X</title></head
  ><!-- ddd --->
  <body></body>
</html>

I have this .prettierrc.json file

{
"singleQuote": true,
"trailingComma": "es5",
"endOfLine": "auto",
"bracketSpacing": true,
"printWidth": 120
}

Any suggestions why this behavior occurs? Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一曲爱恨情仇 2025-02-16 17:36:27

添加此选项

in命令行:

- - - - html-whitespace-Senititive忽略

或在您的.prettierrc.json中:

htmlWhitespaceSentitivity:“ impan of of of of code>

Add this option

In command line :

--html-whitespace-sensitivity ignore

Or in your .prettierrc.json :

htmlWhitespaceSensitivity: "ignore"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文