简体   繁体   English

保留内联注释的 VS Code HTML 格式化程序

[英]VS Code HTML formatter that preserves inline comments

I'm trying to find a decent HTML formatter plugin for VS Code that won't "break" a lot of pre-existing HTML that has inline comments eg我正在尝试为 VS Code 找到一个不错的 HTML 格式化程序插件,它不会“破坏”许多具有内联注释的预先存在的 HTML,例如

<div>hello</div><!-- class="world" -->

Shouldn't turn into this:不应该变成这样:

<div>hello</div>
<!-- class="world" -->

Apparently jsbeautify is not good about this.显然 jsbeautify 对此并不擅长。 I tried prettier and same issue..the comments would wrap.我试过更漂亮和同样的问题……评论会结束。 After a lot of digging I disabled everything but now I don't have basic auto-formatting of html tags to auto-indent etc.经过大量挖掘后,我禁用了所有内容,但现在我没有基本的 html 标签自动格式以自动缩进等。

If anyone has a good vs code setup that addresses this, would highly appreciate if you could share which plugin you're using and any associated plugin settings that may be required to preserve inline comment formatting.如果有人有一个很好的 vs 代码设置来解决这个问题,如果您能分享您正在使用的插件以及保留内联注释格式可能需要的任何相关插件设置,我们将不胜感激。

Thanks,谢谢,

  • S. Arora S.阿罗拉

In settings.json , addsettings.json ,添加

 "[html]": {
        "editor.defaultFormatter": "vscode.html-language-features"
      },

From there, you can search for "whitespace" in the settings UI of VSCode, and configure as you like.从那里,您可以在 VSCode 的settings UI 中搜索“空白”,并根据需要进行配置。

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

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