Jump to content
David Schwartz

formatting HTML code

Recommended Posts

This site https://htmlformatter.com/ does an awesome job of taking a huge glom of unformatted HTML and pretty-printing it so it's super-readable.

 

Are there any components that can do that in Delphi?

 

You'd give it a string or stringstream, and it formats it into another string or stringstream or TStringList (eg., a TMemo)

 

All I can find in Google is how to format Delphi (pascal) code.

Share this post


Link to post

Do you need parsing too, or only to beautify the code? I wrote a unit which beautifies and simplifies (remove idents and formatting to reduce size) XML documents and it's using only string helper functions. It formats a ~14 MB XML file in about 300ms, however this heavily depends on the amount of tags.

Since the structure is very close I suppose it can work with HTML.

 

If you don't want to use components / libraries let me know, I can send you the code.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×