Tidy 导致不良间距问题 (JTidy)

发布于 2024-07-26 12:46:22 字数 447 浏览 5 评论 0原文

我们正在使用 JTidy 来清理一些 html 以进行 sax 处理。 我们在间距问题上遇到了很多麻烦,如下例所示:

Html

<i>stack<span
class="bold">overflow</span></i>

输出“stackoverflow”的

但是...

Post JTidy

<i>stack
<span
class="bold">overflow</span></i>

输出“stackoverflow”的

(注意新的空格)任何人都可以提出修复/处理此问题的建议更好的。 我已经完成了所有 Tidy/JTidy 设置,但没有看到任何可以解释此问题的内容。

We are using JTidy to clean up some html for sax processing. We've had a lot of trouble around spacing issues as shown in this example:

Html

<i>stack<span
class="bold">overflow</span></i>

which outputs "stackoverflow"

But...

Post JTidy

<i>stack
<span
class="bold">overflow</span></i>

which outputs "stack overflow" (note the new space)

Anyone have any advice to fix/handle this better. I've been through all the Tidy/JTidy settings and don't see anything to account for this issue.

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

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

发布评论

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

评论(2

稚气少女 2024-08-02 12:46:22

事实证明这个简单的例子并不能真正说明问题。 实际问题是 Tidy/JTidy 使用默认换行设置,当属性值很长时,该设置会导致上述问题(以及其他各种间距问题)。

一切都已修复:

 jtidy.setWraplen(0);
 jtidy.setWrapAttVals(false);

Turns out this simple example doesn't really show the issue. The actual issue was that Tidy/JTidy was using a default wrapping setting which was causing the above issue (and other various spacing issues) when there were very long attribute values.

Everything was fixed with:

 jtidy.setWraplen(0);
 jtidy.setWrapAttVals(false);
家住魔仙堡 2024-08-02 12:46:22

您使用什么设置? 使用您发布的代码片段上的默认设置从命令行执行 JTidy 会打印以下内容:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<title></title>
</head>
<body>
<i>stack<span class="bold">overflow</span></i>
</body>
</html>

What settings are you using? Executing JTidy from the command line using its default settings on the snippet you posted prints this:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<title></title>
</head>
<body>
<i>stack<span class="bold">overflow</span></i>
</body>
</html>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文