VS Code 的设置 html.format.unformatted 有什么作用?
What does VS Code's setting html.format.unformatted do?
我想弄清楚 VS Code html.format.unformatted
设置的作用,但我做不到。
我在 GitHub 中找到了 this issue and this issue,但它没有任何解释。
有人可以向我解释一下 html.format.unformatted
设置的作用以及它与 html.format.contentUnformatted
设置的区别吗?
经过反复试验,我发现了这一点:
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 上触发自动格式时,STYLE TAG 未格式化且样式标签内容未更改。
使用此配置:
{
"html.format.wrapAttributes": "force-expand-multiline",
"html.format.contentUnformatted" : "style",
//"html.format.unformatted": "style"
}
当我们在上面的示例 html 上触发自动格式时,样式标签被格式化(空格、标识等),样式标签内容未更改。
我想弄清楚 VS Code html.format.unformatted
设置的作用,但我做不到。
我在 GitHub 中找到了 this issue and this issue,但它没有任何解释。
有人可以向我解释一下 html.format.unformatted
设置的作用以及它与 html.format.contentUnformatted
设置的区别吗?
经过反复试验,我发现了这一点:
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 上触发自动格式时,STYLE TAG 未格式化且样式标签内容未更改。
使用此配置:
{
"html.format.wrapAttributes": "force-expand-multiline",
"html.format.contentUnformatted" : "style",
//"html.format.unformatted": "style"
}
当我们在上面的示例 html 上触发自动格式时,样式标签被格式化(空格、标识等),样式标签内容未更改。