Message192558
I have attached a proposed patch.
This makes some design decisions which I would like someone to review:
a) To incorporate pretty-printing into the main write() method rather than adding a separate toprettyxml() method. Disadvantages: greater complexity of _serialize_xml(). Advantages: Reduced duplication of code, easy to add other pretty-printing (eg HTML) in the same way.
b) Existing whitespace on the ends of existing text is mutated. Disadvantages: existing whitespace content may get changed. Advantages: Greater readability (which is the whole point), idempotence of pretty-printing.
c) Not to add a trailing newline. I am undecided as to whether this is a bad idea or a good one, but am documenting it to ensure it gets visibility.
Of these, I think b) is the only potentially controversial one, and notably its behaviour differs from minidom's toprettyxml. I think it's the right thing to do though; and for the cases where whitespace is important, perhaps we can respect the xml:space attribute when pretty-printing?
http://www.w3.org/TR/xml/#sec-white-space
If these design choices are deemed suitable I'm happy to update the patch to support pretty-printing HTML also. |
|
Date |
User |
Action |
Args |
2013-07-07 14:23:14 | alex.henderson | set | recipients:
+ alex.henderson, eric.snow |
2013-07-07 14:23:14 | alex.henderson | set | messageid: <1373206994.89.0.82581289096.issue17372@psf.upfronthosting.co.za> |
2013-07-07 14:23:14 | alex.henderson | link | issue17372 messages |
2013-07-07 14:23:14 | alex.henderson | create | |
|