velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Serge Knystautas <ser...@lokitech.com>
Subject Re: other options besides jtidy
Date Wed, 13 Aug 2003 17:41:28 GMT
JTidy is not very *actively* maintained, but it's been around for some 
time, and activity comes and goes like any project.  We use it in a few 
places that wants cleansed HTML.  Our content management system offers a 
Tidy error report on a page or site, but in the end we usually end up 
just restricting what users can edit.

If you really just want extra whitespace removed, I would think you 
could just do this....

String original = <what I started with>
StringBuffer result = new StringBuffer(original.length());
StringTokenizer tokenizer = new StringTokenizer(original, " \r\t\n", false);
while (tokenizer.hasMoreTokens()) {
     result.append(tokenizer.nextToken()).append(' ');
}

This will strip all spots where you have more than one whitespace 
elements.  It would screw up something in a <pre> tag, but that's 
related to whatever whitespace removal approach you take.

-- 
Serge Knystautas
President
Lokitech >> software . strategy . design >> http://www.lokitech.com
p. 301.656.5501
e. sergek@lokitech.com

Brian W. Young wrote:
> I've read the discussions here before about whitespace and formatting 
> issues.  One suggestion was to pipe output through JTidy.  I'd consider 
> giving this a shot, but I'm a bit concerned about the JTidy project- it 
> doesn't appear to be actively maintained, making it a poor compliment to 
> Velocity which appears to be very well maintained.
> 
> Thoughts on this or suggestions of another Tidy-style library to use?  I 
> use Velocity to create HTML once that gets written to disk and may be 
> edited by users after that so I'd really like to pass my output through 
> a formatter.  Your thoughts on the best practices here for a robust 
> solution would be appreciated.  My users may also modify the templates 
> as well and I don't want to restrict them to be expected to use "strict" 
> markup either... i.e. close every <br> tag or else things are busted.  
> So I think that rules out trying to use an XML style API.


Mime
View raw message