tags:

views:

25

answers:

2

Hi there

I m pretty sure there is an open source/free library for .net out there that does this already, so before I reinvent the wheel...

I need to grab an some sort of input: could be a file, a string, etc and format it nicely. It will mostly be HTML and javascript, if CSS is supported nice.

any ideas?

A: 

try: http://astyle.sourceforge.net/

Tzury Bar Yochay
A: 

I'm not sure if you're going to find a pretty printer that handles both HTML and JS.

There is certainly HTML tidy that will do the majority of the work, but to format the code you may have to use an app that specializes in C syntax. Tzury recommends Artistic Style.

Unfortunately, these tools don't really interoperate, so you will probably have to do it in 2 passes.

  1. Run HTML tidy,
  2. Scan through the tidied doc, pull out JS, format using a pretty pinter, then insert back into the document.
Frank Krueger