为什么 PyCharm 格式化程序在重新格式化 HTML 文件时在 <script> 和 <style> 标记中附加一个新行?

Why does PyCharm formatter append a new line in <script> and <style> tags whenever a HTML file is reformatted?

如果 HTML 文件看起来像:

<style>
h1 {text-align:center;}
</style>
.
.
.
.
.
<script>
var a;
</script>

然后在使用 ( Code > Reformat File... ) 或 Ctrl+Alt+L 格式化 HTML 文件后,HTML 文件看起来像:

<style>
h1 {text-align:center;}
           <!-- New line got appended -->
</style>
.
.
.
.
.
<script>
var a;
             <!-- New line got appended -->
</script>

那么,每当 HTML 文件在 PyCharm 中重新格式化时,我们如何才能停止在 <script><style> 标签中添加新行??

因此,每当 HTML 文件在 PyCharm 中重新格式化时,停止在 <script><style> 标签中添加新行的方法是:

File > Settings... > Editor > Code Style > HTML > Other > Keep white spaces inside:

然后将值 ,script,style 添加到 Keep white spaces inside: