简体   繁体   English

整齐导致间距问题不佳(JTidy)

[英]Tidy causing bad spacing issues (JTidy)

We are using JTidy to clean up some html for sax processing. 我们正在使用JTidy清理一些用于sax处理的html。 We've had a lot of trouble around spacing issues as shown in this example: 如示例所示,我们在间距问题上遇到了很多麻烦:

Html HTML

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

which outputs "stackoverflow" 输出“ stackoverflow”

But... 但...

Post JTidy 发表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. 我已经完成了所有Tidy / JTidy设置,但看不到有什么可以解决此问题的。

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. 实际的问题是Tidy / JTidy使用默认的包装设置,当属性值很长时会导致上述问题(以及其他各种间距问题)。

Everything was fixed with: 一切都固定为:

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

What settings are you using? 您正在使用什么设置? Executing JTidy from the command line using its default settings on the snippet you posted prints this: 使用您发布的代码段中的默认设置从命令行执行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>

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

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