简体   繁体   English

Prettier 不格式化 HTML

[英]Prettier does not format HTML

Prettier has just stopped working and is not formatting HTML in my VSCode. Prettier 刚刚停止工作,并且没有在我的 VSCode 中格式化 HTML。 In the output I get: ["ERROR" - 5:00:45 PM] Error formatting document.在 output 中,我得到: ["ERROR" - 5:00:45 PM] 格式化文档时出错。 ["ERROR" - 5:00:45 PM] Unexpected closing tag "p". [“错误”-下午 5:00:45] 意外的结束标签“p”。 It may happen when the tag has already been closed by another tag.当标签已被另一个标签关闭时,可能会发生这种情况。 For more info see https://www.w3.org/TR/html5/syntax.html#closing-elements-that-have-implied-end-tags (62:90)有关更多信息,请参阅https://www.w3.org/TR/html5/syntax.html#closure-elements-that-have-implied-end-tags (62:90)

Does anyone know what I can do to get working again?有谁知道我可以做些什么来重新开始工作? Ive checked my various settings and not been able to see anything wrong.我检查了我的各种设置,但没有发现任何问题。

I had the same problem and finally solved right now.,,: I have in settings the default fomratter as esbenp.prettier-vscode.我有同样的问题,现在终于解决了。,,:我在设置中将默认格式设置为 esbenp.prettier-vscode。 then what I have done is in the html file.那么我所做的是在 html 文件中。 ctrl+shift+P --> preferences. ctrl+shift+P --> 首选项。 configure language specific settings... then u search html and then u should have open the settings.json.配置语言特定设置...然后你搜索 html 然后你应该打开 settings.json。 in there i just paste this在那里我只是粘贴这个

{
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"editor.formatOnType": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[html]": {
    "editor.defaultFormatter": "vscode.html-language-features"
}

} }

and I don't know why but works我不知道为什么但是有效

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

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