我正在使用 JTidy(HTML Tidy 库的 java 端口)来清理一些现有网站。当我使用 JTidy 的配置时,它似乎非常严格,最终会切断页面底部(糟糕的标记)。
当我仅通过 w3c HTML 验证器工具运行相同的标记时,它会清理它,但在重写时更加智能;它似乎不是砍掉标签,而是智能地猜测丢失的标签在哪里,并相应地更新结构。
有人知道 w3c 使用的 HTML-Tidy 配置吗?
我的jtidy配置如下:
Tidy tidy = new Tidy();
tidy.setTidyMark(false);
tidy.setXHTML(true);
tidy.setXmlOut(false);
tidy.setNumEntities(true);
tidy.setSpaces(2);
tidy.setWraplen(2000);
tidy.setUpperCaseTags(false);
tidy.setUpperCaseAttrs(false);
tidy.setQuiet(false);
tidy.setMakeClean(true);
tidy.setShowWarnings(true);
tidy.setBreakBeforeBR(true);
tidy.setHideComments(true);
W3C 验证器使用的整洁配置可在这里