0

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

2 Answers 2

2

Check out this Ruby interface to the HTML Tidy library.

Sign up to request clarification or add additional context in comments.

1 Comment

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

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.

2 Comments

I agree. But consider this as a unique requirement. We need to achieve this somehow. Thanks for your comments.
I also like clean, and predictive html because of unit testing. Whitespaces and newlines always hard to take care in string equals operations

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.