XMLPRETTY(1p)

πŸ“¦
version 0.23 Β· 3 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

xmlpretty β€” your friendly neighborhood XML pretty printer, no cap. This is the manual for XMLPRETTY(1p), a page from the User Contributed Perl Documentation collection, and it's about to become your new hyperfixation. πŸ¦‹


✨ SYNOPSIS ✨

xmlpretty [--options] [filename]

That's it. Options first, file at the end, and the pretty comes out on stdout. Slay.


🌸 DESCRIPTION 🌸

xmlpretty is the commandline interface to XML::Handler::YAWriter, and lowkey it's a whole tool for adding and removing pretty printing on XML files. Both directions, bestie. It does not pick sides. πŸ’…

And it's not just one method either β€” xmlpretty has several ways to add human readability. Choose your fighter:

If you want to add readability without adding so-called ignorable whitespace, do it like this:

  $ xmlpretty --AddHiddenNewline \
              --AddHiddenAttrTab \
          --CatchEmptyElement \
          uglyfile.xml > prettyfile.xml

But if you don't wanna process the file further and just want it human readable, add visible whitespace instead, like so:

  $ xmlpretty --PrettyWhiteNewline \
              --PrettyWhiteIndent \
          --CatchEmptyElement \
          uglyfile.xml > prettyfile.xml

You can also use YAWriter to clean whitespace out of XML documents. It's giving ✨vacuum cleaner✨, and it works in 99% of the cases where you're trying to get rid of ignorable whitespace caused by the various forms of pretty printing:

  $ xmlpretty --NoWhiteSpace \
              --NoComments \
              --AddHiddenNewline \
          --AddHiddenAttrTab \
          --CatchEmptyElement \
          prettyfile.xml > cleanfile.xml

πŸŽ€ Options πŸŽ€

Options are given in a gnu like --option idiom. Very demure, very mindful. πŸ™ˆ

  • --AddHiddenNewline (boolean) β€” adds a hidden newline before ">"
  • --AddHiddenAttrTab (boolean) β€” adds a hidden tabulation for attributes
  • --CatchEmptyElement (boolean) β€” catches empty Elements and applies "/>" compression
  • --CatchWhiteSpace (boolean) β€” catches whitespace with comments
  • --IsSGML (boolean) β€” this one makes start_document, processing_instruction and doctype_decl show up as SGML. And ngl the SGML is still well-formed of course, if your SAX events are well-formed. That's the deal. 🀝
  • --NoComments (boolean) β€” supresses Comments
  • --NoDTD (boolean) β€” supresses DTD
  • --NoPI (boolean) β€” supresses Processing Instructions
  • --NoProlog (boolean) β€” supresses the <?xml ... ?> Prolog
  • --NoWhiteSpace (boolean) β€” supresses WhiteSpace, so you can clean documents from prior pretty printing
  • --PrettyWhiteIndent (boolean) β€” adds visible indent before any eventstring
  • --PrettyWhiteNewline (boolean) β€” adds visible newlines before any eventstring
  • --SAX1 (boolean, not yet implemented 😭) β€” outputs only SAX1 compilant eventstrings
Two names in that list are spelled "Supress" in the original, and I'm keeping them exactly as they are. Don't come for me, I don't make the rules. πŸ™ˆ

πŸ› Bugs πŸ›

Automatic recoding between 8bit and 16bit does not yet work correctly. Not me being dramatic β€” that's literally the bug note. πŸ’€

Here's the tea: the author has Perl-5.6 at home, and there he can specify use utf8; in the right places to make recoding work. But he dislikes saying use 5.00555; because many systems run 5.00503. So yeah. That's the whole saga. 😭


πŸ‘‘ AUTHOR πŸ‘‘

Michael Koehne, Kraehe@Copyleft.De


🫢 Thanks 🫢

"Derksen, Eduard (Enno), CSCIO" <enno@att.com> helped with the Escape hash and gave quite a lot of useful comments. King behavior, honestly. ✨


🌈 SEE ALSO 🌈

perl and XML::Parser::PerlSAX β€” go read those next, iykyk. πŸ“š


okay that's the whole page, bestie!! this was written against perl v5.38.2 and dated 2024-03-08, and that's your official XMLPRETTY(1p) sign-off. go make some XML pretty. periodt. πŸ’…πŸŽ€πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from