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: <5.0.2.1.0.20011220123657.00a0f520@shawmail>
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 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>:

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

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

<xml>
     <para>
         <sentence>Mary had a
         <strong>little</strong>

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

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

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



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:

wrap:100
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/

So:

* 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 
this?]

* 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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 3 April 2012 06:13:49 GMT