首页 > 解决方案 > 配置 prettier 以在 html 中保留空白喜欢

问题描述

从 Prettier 文档中,我看到处理空白行的一般方法是:(来源

空行

事实证明,空行很难自动生成。> Prettier 采用的方法是保留原始源代码中的空行。> 还有两个附加规则:

  • Prettier 将多个空行折叠成一个空行。
  • 块(和整个文件)开头和结尾的空行被删除。(不过,文件总是以一个换行符结尾。)

但如果我尝试:

<div>

  <!-- I want to preserve the blank line above -->
  <div>
  </div>

  <!-- the line above this is preserved, good! -->
  <div>
  </div>

</div> <!-- and how about preserving the line above this one -->

我明白了

<div>
  <!-- I want to preserve the blank line above -->
  <div></div>

  <!-- the line above this is preserved, good! -->
  <div></div>
</div>
<!-- and how about preserving the line above this one -->

看看这个现场更漂亮的游乐场

我怎样才能告诉 prettier 保留那些空行?

标签: htmlconfigurationprettierblank-line

解决方案


推荐阅读