diff --git a/pypeg2/xmlast.py b/pypeg2/xmlast.py index b02882f..0145a34 100644 --- a/pypeg2/xmlast.py +++ b/pypeg2/xmlast.py @@ -126,6 +126,7 @@ def thing2xml(thing, pretty=False, object_names=False): if pretty: warnings.warn("lxml is needed for pretty printing", ImportWarning) + etree.indent(tree) return etree.tostring(tree) diff --git a/samples/sample2.py b/samples/sample2.py index edd80ca..5fb1711 100644 --- a/samples/sample2.py +++ b/samples/sample2.py @@ -48,7 +48,7 @@ that=new one once=anything twice=goes [Number 3] -... + pyPEG contains an XML backend, too: @@ -63,14 +63,13 @@ pyPEG contains an XML backend, too: anything goes -
+
-... In this sample the tree contains named objects only. Then we can output object names as tag names. Spaces in names will be translated into underscores. ->>> print(thing2xml(ini_file, pretty=True, object_names=True).decode()) # doctest: +SKIP +>>> print(thing2xml(ini_file, pretty=True, object_names=True).decode()) something @@ -80,9 +79,8 @@ names as tag names. Spaces in names will be translated into underscores. anything goes - + -... """ from __future__ import unicode_literals, print_function