开发者

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

开发者 https://www.devze.com 2022-12-23 13:33 出处:网络
HTML Tidy has this infuriating habit of putting a newline before the closing tag. For example: <p>Some text</p>

HTML Tidy has this infuriating habit of putting a newline before the closing tag. For example:

<p>Some text</p>

becomes

开发者_开发问答<p>Some text
</p>

How do I tell Tidy to keep the closing tag on the same line as the end of the content?

Btw, I am running Tidy through Notepad++, if that makes any difference.


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);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号