Reputation: 15454
I am using following command to format HTML:
tidy -xml --merge-divs no --wrap 0 --force-output yes --indent auto --indent-spaces 2 --quiet yes
It works fine except it automatically closes tags like this:
<br> -> <br></br>
<br><br> -> <br><br></br></br>
<div><input><span></span></div> -> <div><input><span></span></input></div>
As you can see it tries to close every tag - how I can fore it not to do that and leave tags untouched or at least close them "inline" like this:
<br><br> -> <br/><br/>
The closest I want is using this command:
tidy -asxhtml --hide-endtags yes --doctype omit --merge-divs no --wrap 0 --force-output yes --indent auto --indent-spaces 2 --quiet yes
However from this HTML:
<div><input type="text"><span>abc</span></div><br><br>
It generates this:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content="HTML Tidy for Mac OS X (vers 31 October 2006 - Apple Inc. build 15.12), see www.w3.org" />
<title></title>
</head>
<body>
<div>
<input type="text" /><span>abc</span>
</div><br />
<br />
</body>
</html>
</div>
?I found option show-body-only
which does not output html, body, etc tags.
However still output is like this:
<div>
<input type="text" /><span>abc</span>
</div><br />
<br />
Upvotes: 1
Views: 1048
Reputation: 7727
You're passing the wrong flags. Quoting man tidy
:
-xml specify the input is well formed XML (input-xml: yes)
but what you probably want is
-asxml, -asxhtml convert HTML to well formed XHTML (output-xhtml: yes)
Upvotes: 2