简体   繁体   English

有没有办法防止Prettier触摸<pre> blocks in HTML files?

[英]Is there a way to prevent Prettier from touching <pre><code> blocks in HTML files?

Prettier does a very nice job on HTML generally, but indents pre>code blocks. Prettier 通常在 HTML 上做得很好,但缩进了 pre>code blocks。

I always want pre>code blocks unindented.我总是希望预> 代码块不缩进。

Seems like I should be able to configure this in .prettierignore, but can't find a way that works.似乎我应该能够在 .prettierignore 中配置它,但找不到有效的方法。

blocks like:块像:

<pre class="line-numbers"><code class="language-json">"operations": [
    "video-cloud/video/all",
    "video-cloud/playlist/all",
    "video-cloud/sharing-relationships/all",
    "video-cloud/notifications/all"
]</code></pre>

Get indented like this:像这样缩进:

      <pre class="line-numbers"><code class="language-json">"operations": [
    "video-cloud/video/all",
    "video-cloud/playlist/all",
    "video-cloud/sharing-relationships/all",
    "video-cloud/notifications/all"
]</code></pre>

I want the block left untouched.我希望块保持原样。

您可以忽略某些文件,但不能忽略部分代码。

Quoting from a deleted answer:引用已删除的答案:

I personally don't use the extension but it seems like prettier has build in configuration for it: https://prettier.io/docs/en/ignore.html我个人不使用该扩展程序,但似乎 prettier 已为其内置配置: https : //prettier.io/docs/en/ignore.html

IIUIC, the solution is IIUIC,解决方案是

<!-- prettier-ignore-start -->
block to keep
<!-- prettier-ignore-end -->

Voting to undelete the answer by "cas vl" as it led me to the solution in seconds.投票通过“cas vl”取消删除答案,因为它让我在几秒钟内找到了解决方案。

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

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