如何强制在新行上关闭HTML标签? [英] How to force closing HTML tags on a new line?

查看:177
本文介绍了如何强制在新行上关闭HTML标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在VS Code中,我广泛使用Beautify.但是令我不安的是,结束标记始终与浮动"文本或自动结束标记位于同一行.例如,在Beautify之前:

In VS Code, I use Beautify extensively. But it unnerves me that closing tags always wrap on the same line as "floating" text, or self-closing tags. For instance, before Beautify :

<div class="wrap">
    <img src="/wp-content/uploads/2018/08/image.png">
</div>
<div class="wrap">This is just some text
    <strong>but it needs to be emphasized</strong>! And then some...
</div>

在美化之后:

<div class="wrap">
    <img src="/wp-content/uploads/2018/08/image.png"> </div>
<div class="wrap">This is just some text
    <strong>but it needs to be emphasized</strong>! And then some... </div>

是否有一个设置或另一个扩展名可以帮助使代码更接近第一个示例中的样子,或者我做错了吗?

Is there a setting, or another extension that could help get the code closer to what it looks like in the first example, or am I just doing things wrong ?

在大多数时候,这并不重要,除了让我觉得有点丑陋外,但是昨天我看到它实际上在Wordpress中造成了问题,我只是不能再使用Beautify,否则可能会破坏格式

It doesn't matter much most of the time, other than being a bit ugly to my taste, but yesterday I saw that it actually created problems with Wordpress, I just can't use Beautify anymore, it risks breaking the formatting.

推荐答案

没有选择强制将结束标记插入新行.

There isn't an option to force the end tags to new lines.

一个有用的设置是preserve_newlines.启用该选项后,如果您将标签放在自己的行中,就可以避免将其拉回到同一行.

One setting that helps is preserve_newlines. Enabling that should keep your tags from getting pulled back to the same line if you have them on their own line.

js-beautify(Beautify for VSCode的基础库)的1.8.1版改进了该区域的行为,但是仍然没有选择强制将行尾标签强制换成新行.

Version 1.8.1 of js-beautify (the library underlying Beautify for VSCode) improves the behavior in this area, but still doesn't have an option to force the end tags to new lines.

围绕此问题已提出了多个问题,包括#1468 #1413 .随时欢迎PR.

Several issues have been filed around this, including #1468 and #1413. PRs are always welcome.

这篇关于如何强制在新行上关闭HTML标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆