Page 1 of 1

XML Pretty Print functionality

Posted: Wed Mar 03, 2004 3:13 pm
by marc_scheuner
Folks,
Dealing with a lot of XML files lately, I've often longed for a function in TextPad that would allow me to "pretty print" (or rather: pretty format) a messed-up XML file.

E.g. I'd love to see a function in TextPad that would take an XML file, make sure to put all new elements onto a line of their own, add the perfect indenting to the XML stream, and so forth...

Turn <xml..><root><elem id="1"><subelem sid="2">..</subelem></elem></root>

into

<xml.....>
<root>
<elem id="1">
<subelem sid="2">......</subelem>
</elem>
</root>

or something like that. It'd be nice if I could specify
a) the indentation per "hiearchy level" (e.g. one tab, 2 spaces etc.)
b) whether or not to put a closing </tag> onto the same line or a separate one

With XML being widely used and adopted, I think a lot of folks could benefit from something like this

Posted: Wed Mar 03, 2004 5:20 pm
by talleyrand
Cooktop already does a good job of cleaning up XML. I can't say much for the rest of the editor but you get what you pay for. ;)

Posted: Thu Mar 04, 2004 7:37 pm
by saubin
I can't tell you how many time's functionality like this was included in TextPad. Anyone know if a poll for this exists?

Posted: Fri Mar 05, 2004 6:29 pm
by BenjiSmith
Well, it'd also be nice to pretty-print my Java & Perl & php code. But , to accomplish that, TextPad would have to include parsers for all of these languages, and that would really bulk it up, with very little (though definitely some) benefit.

It would even be pretty cumbersome to include a full XML parser (which would be necessary for the pretty-printer to function correctly).

There are command-line apps that can pretty-print source code for various languages, and I think that's where the functionality belongs. It's currently possible to send the contents of a file to a pretty-printer and get the results back. It's clunky, and I'd like to see the external-command-calling interface improved somewhat, but I don't think pretty-printing belongs in the TextPad core.

Posted: Sat Mar 06, 2004 10:02 am
by gracefool
I second that, Benji.

People are continually suggesting things like this. At most, they should be an add-on (make them yourself, or get it from someone else who's already done it). I can't see any reason why they should be an essential part of Textpad.