[prev in list] [next in list] [prev in thread] [next in thread] 

List:       velocity-user
Subject:    Re: other options besides jtidy
From:       "Brian W. Young" <byoung () decadesystems ! com>
Date:       2003-08-15 15:59:32
[Download RAW message or body]

Well, I'm all for giving JTidy a try, in testing it seems to work okay.

One question- what is the best way to pipe the output through Tidy when 
merging your templates?  It takes an InputStream and OutputStream. (My 
HTML output  is aways a file on disk.) Velocity's template.merge() takes 
a BufferedWriter.  It is almost like I'd want a gender changer (to lack 
a better term) to convert the BufferedWriter passed into 
template.merge() into an InputStream that could be passed into Tidy.

The only option I can think of involves a two stage process of writing 
Velocity's output to a string in memory or a temp file, neither of which 
I like.  I'd like to just hook the streams up together and let it go.  
Any ideas?

Thanks,
Brian

Serge Knystautas wrote:

> 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.
>




---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic