如何让 HTML Tidy 在关闭标签之前不添加换行符?

发布于 2024-08-26 14:02:24 字数 270 浏览 5 评论 0原文

HTML Tidy 有一个令人恼火的习惯,即在结束标记之前放置换行符。例如:

<p>Some text</p>

成为

<p>Some text
</p>

如何告诉 Tidy 将结束标记与内容末尾保持在同一行?

顺便说一句,我正在通过 Notepad++ 运行 Tidy,如果这有什么区别的话。

HTML Tidy has this infuriating habit of putting a newline before the closing tag. For example:

<p>Some text</p>

becomes

<p>Some text
</p>

How do I tell Tidy to keep the closing tag on the same line as the end of the content?

Btw, I am running Tidy through Notepad++, if that makes any difference.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

溺ぐ爱和你が 2024-09-02 14:02:24

确保vertical-space设置为no。经过多次挫折后,我了解到 switch 所做的唯一一件事就是通过在您不需要的地方添加换行符来搞砸您已经格式化的 html。

这就是我用于微创整理的方法(不添加 doctypes/head 标签等):

tidy -mqi --doctype omit --show-body-only true --show-warnings no --vertical-空格无--wrap 0

Make sure vertical-space is set to no. After much frustration I learned the only thing that switch does is screw up your already somewhat-nicely formatted html by adding newlines where you don't want them.

This is what I use for minimally-invasive tidying (no adding doctypes/head tags, etc.):

tidy -mqi --doctype omit --show-body-only true --show-warnings no --vertical-space no --wrap 0

°如果伤别离去 2024-09-02 14:02:24

嗯,我在 Windows 中看不到它。

我正在使用 Tidy 和 ruby

   @tidy.options.output_xhtml = true
   @tidy.options.show_body_only = true
   @tidy.clean('<p>Some text</p>')

​​ 我还在 unbuntu 中运行了 tidy 脚本(tidy -m test.htm),但没有看到这个问题。
您可以使用以下选项控制间距
http://tidy.sourceforge.net/docs/quickref.html#PrettyPrintHeader

hmm I don't see it in windows.

I am using Tidy with ruby

   @tidy.options.output_xhtml = true
   @tidy.options.show_body_only = true
   @tidy.clean('<p>Some text</p>')

I also ran the tidy script in unbuntu (tidy -m test.htm) but did not see that problem.
You can control the spacing using the options at
http://tidy.sourceforge.net/docs/quickref.html#PrettyPrintHeader

四叶草在未来唯美盛开 2024-09-02 14:02:24

在 PHP 中你可以使用:

$buffer = preg_replace('/\n<\//smUi','</',$buffer);

In php you can use:

$buffer = preg_replace('/\n<\//smUi','</',$buffer);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文