views:

57

answers:

2

Hi All,

Is there any Ruby library available to format the HTML source. By formatting I mean removing the extra spacing, apply proper indentation etc.

I am already using Hpricot for parsing HTML. It would be nice if Hpricot could do this job. But I am not stick with Hpricot for the formatting stuff.

Thanks, Imran

A: 

Extra spacing and formatting don't really matter in HTML, so regardless of the formatting and white space, the browser should display the code as the same.

Parker
I agree. But consider this as a unique requirement. We need to achieve this somehow. Thanks for your comments.
Imran
Not for parsing, but it does if you want your code readble
James Wiseman
Yes, this is why I want to apply formatting.
Imran
+2  A: 

Check out this Ruby interface to the HTML Tidy library.

michaelmichael
Thanks Michael, I'll have a look at it. Thanks again.
Imran