Attached is a test version that uses .toprettyxml(indent=' '...) instead of just .toxml() for the content.opf and toc.ncx files.
I honestly don't see the existing output as problem--it's a machine written file for machines to read. But I'm willing to change to pretty print output as long as it doesn't break machine readability.
I don't remember the details, but I do have some
past evidence that pretty printed XML was a problem at one time.