我试图弄清楚VS Code html.format.unformatted
设置的作用,但我不能。
我在GitHub中找到了this issue和this issue,但是它什么也没解释。
有人可以向我解释html.format.unformatted
设置的功能以及与html.format.contentUnformatted
设置的不同之处吗?
答案 0 :(得分:1)
经过反复试验,我发现了这一点:
TLDR:
html.format.unformatted
:不格式化标签本身也不格式化内容html.format.contentUnformatted
:将格式化标签,但不格式化内容来源(不是很清楚,恕我直言):https://code.visualstudio.com/Docs/languages/html
示例html代码(无效,我知道,但此处不相关):
<body>
<style class="foo" class="foo" class="foo" >
.foo {
background-image: 'bar.jpeg';
background-size: cover;
background-position-x: 50%;
background-position-y: 50%;
}
</style>
<div class="foo">
<div>
<div></div>
whatever
<div></div>
</div>
</div>
</body>
使用此配置:
{
"html.format.wrapAttributes": "force-expand-multiline",
//"html.format.contentUnformatted" : "style",
"html.format.unformatted": "style"
}
当我们在上面的html示例中触发自动格式设置时,“样式标签”未格式化,并且样式标签内容未更改。
使用此配置:
{
"html.format.wrapAttributes": "force-expand-multiline",
"html.format.contentUnformatted" : "style",
//"html.format.unformatted": "style"
}
当我们在上面的示例html上触发自动格式时,STYLE TAG被格式化(空格,ident等),样式标签的内容未更改。