W3C home > Mailing lists > Public > html-tidy@w3.org > October to December 2001

Simple pretty printing using tidy

From: Tim Green <tcg@TrainsCan.com>
Date: Thu, 20 Dec 2001 13:57:29 -0700
To: html-tidy@w3.org
Message-id: <>
I must be missing something!  tidy comes so close to doing what I want...

Situation.  I'm trying to use tidy to pretty-print xml code which I 
eventually turn into XHTML.  The code contains a lot of standard (X)HTML 
tags.  However tidy throws a newline before and two newlines after every 
set of tags I consider to be inline.  Here's a simplified example:

before tidy-ing >>>>>>>>>>>>>>>>>>>>>>>>>>>>>:

<sentence>Mary had a <strong>little</strong> lamb whose fleece was white as 

after tidy-ing >>>>>>>>>>>>>>>>>>>>>>>>>:

         <sentence>Mary had a

         lamb whose fleece was white as snow.</sentence>

What I want, but not getting out of tidy >>>>>>>>>>>>>>>>>:

         <sentence>Mary had a  <strong>little</strong> lamb whose fleece 
was white as snow.</sentence>

I would rather that everything between <sentence> and </sentence> stay 
together, not with the <strong>...</strong> on a separate line, and 
certainly not followed by a blank line.  "Aha!" I thought, that's what the 
"new-inline-tags" parameter is all about.  But nothing I put in 
new-blocklevel-tags or new-inline-tags seems to make any difference.

Here's my config file:

indent: auto
indent-spaces: 4
input-xml: yes
output-xml: yes
write-back: yes
new-inline-tags: strong, em
new-blocklevel-tags: para, sentence
force-output: yes

I get the same behaviour from several different versions of tidy, the 
latest being HTML tidy for windows built Sep 15 2001.  I've read all the 
documentation I can find, including http://www.w3.org/People/Raggett/tidy/ 
and http://tidy.sourceforge.net/


* am I missing something or is there something I don't understand about 
tidy to get this to work? [What's "new-inline-tags" about if not to control 

* or am I trying to hammer in a nail with a pair of pliers?  [Is there 
something that works better on straight XML / XHTML input?]

Thanks for any illumination on this...!

######    |\^/|    Timothy C. Green, CD, PEng, MEng
###### _|\|   |/|_  tcg@TrainsCan.com
###### >         <  TrainsCan, RailWeb
######  >_./|\._<  http://www.TrainsCan.com
Received on Thursday, 20 December 2001 15:57:47 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:38:51 UTC