How do I get HTML Tidy to not put newline before closing tags?

大憨熊 提交于 2019-11-29 03:13:40

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

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

In php you can use:

$buffer = preg_replace('/\n<\//smUi','</',$buffer);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!