HTML Tidy 删除有条件的注释
我正在使用 HTML tidy 并且我已经查看了 < a href="http://tidy.sourceforge.net/docs/quickref.html#preserve-entities" rel="nofollow">此处的配置选项。
我已经使用了这个选项:
$config = array(
'hide-comments' => 1
);
但是,它删除了这样的注释:
<!-- Test -->
和这个:
<!--[if IE 6]>Special instructions for IE 6 here<![endif]-->
如果删除后者,我知道它仍然是一个注释,但它有一个目的 - 也许我应该使用另一个选项?
I am making use of HTML tidy and I've had a look at the config options here.
I've made use of this option:
$config = array(
'hide-comments' => 1
);
However, it removes comments such as this:
<!-- Test -->
and this:
<!--[if IE 6]>Special instructions for IE 6 here<![endif]-->
Should it be removing the latter, I know its still a comment but it serves a purpose - maybe I should use another option?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我很确定没有选项。毕竟它是 HTML 注释。我建议你找到一个替代方案,或者保留 HTML 注释。它们不会那么重。
I'm pretty sure there is no option for it.. After all it is a HTML comment. I would recommend you find an alternative, or keep the HTML comments.. They can't be that heavy.
不,没有其他选项可以删除这样的评论,因为它们依赖于浏览器。
HTML Tidy 无法识别注释内容,它只是通过类似于正则表达式规则的方式将其删除。
此行为是一个功能,而不是一个错误。
信息:
http://tidy.sourceforge.net/docs/quickref.html
http://sourceforge.net/tracker/?func=detail&aid=2811312&group_id=27659&atid=451767
HTML Tidy,不要移动这些评论!
No, there is no other option to remove comments like this, because they are browser-dependent.
HTML Tidy is not recognizing content of comment, it just removes it by something similar to regexp rule.
This behavior is a feature, not a bug.
Info:
http://tidy.sourceforge.net/docs/quickref.html
http://sourceforge.net/tracker/?func=detail&aid=2811312&group_id=27659&atid=451767
HTML Tidy, Don't move those comments!
只需使用 Pretty Diff 即可。它是比 Tidy 更完整的算法,并且不会删除您的注释或对输入的完整性做出假设。
http://prettydiff.com/?m=beautify
Just use Pretty Diff. It is a more complete algorithm than Tidy and it does not remove your comments or make assumptions about the completeness of your input.
http://prettydiff.com/?m=beautify