Another question about formatting

Is there a way of saying in lxml: “if the element is <w> or <pc>, indent it by two spaces from the left margin, else indent the element by six spaces” ? In the long texts I deal with, the typical hierarchical indentation doesn’t help much with readability. On the other hand, some <w> elements with their attributes can take up a whole line or more, so there is an advantage of keeping them as close to the beginning of a line. In my project, the readability of the printed XML is a non-trivial advantage: there is a lot of data checking and manual editing. Martin Mueller

Martin Mueller schrieb am 28.08.19 um 06:06:
The pretty-printing support (even the new one that is scheduled for lxml 4.5) is not *that* configurable. I suggest you copy this recipe and adapt it to your needs: http://effbot.org/zone/element-lib.htm#prettyprint Stefan

Martin Mueller schrieb am 28.08.19 um 06:06:
The pretty-printing support (even the new one that is scheduled for lxml 4.5) is not *that* configurable. I suggest you copy this recipe and adapt it to your needs: http://effbot.org/zone/element-lib.htm#prettyprint Stefan
participants (2)
-
Martin Mueller
-
Stefan Behnel