XMLPRETTY(1p)
π 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 makesstart_document,processing_instructionanddoctype_declshow 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
- debian trixie: libxml-handler-yawriter-perl 0.23-9 Β· GPL
- ubuntu resolute: libxml-handler-yawriter-perl 0.23-9 Β· GPL
- ubuntu stonking: libxml-handler-yawriter-perl 0.23-9 Β· GPL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms