Support for pretty formatting XML documents
Similar to REXML it would be nice if Oga had a way to spit out a pretty formatted XML document including correct indentation and all that.
Spec (as of June 27th, 2017)
-
to_xmlon the various node types should take a**kwargsargument which is passed toXML::Generator#initialize -
XML::Generator#initializeshould take two additional keyword arguments:pretty(defaultfalse) andindent(default 4 spaces), producing the argument listinitialize(root, pretty: false, indent: ' ') - A user should be possible to specify its own indent string in
to_xmlusingto_xml(indent: ' ')to indent with 2 spaces orto_xml(indent: "\t")to indent with tabs - If
prettyistruethen XML is pretty printed, and for every element we descend into we add an indentation level. The easiest way is to keep track of anindentcounter which is passed down into the methods called for generating the XML of elements - Tests can be added to
spec/oga/xml/generator_spec.rbin the#to_xmldescribeblock