简体   繁体   English

Prettier 2.6.2 对 html 代码进行了奇怪的更改

[英]Prettier 2.6.2 makes strange changes to the html code

I am new to prettier.我是新来的漂亮。 I have this strange phenomena in this HTML, after running prettier:在运行更漂亮之后,我在这个 HTML 中有这个奇怪的现象:

<!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我有这个 .prettierrc.json 文件

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

Any suggestions why this behavior occurs?有什么建议为什么会发生这种行为? Thank you.谢谢你。

Add this option添加此选项

In your command line :在您的命令行中:

--html-whitespace-sensitivity ignore

Or in your .prettierrc.json :或在您的.prettierrc.json中:

htmlWhitespaceSensitivity: "ignore"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM