From 50d2b103156d2c305e332bc521c68719e162fc11 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 5 Jul 2021 11:38:14 +0530 Subject: [PATCH] Pretty print the metadata in txtz files --- src/calibre/ebooks/conversion/plugins/txt_output.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/calibre/ebooks/conversion/plugins/txt_output.py b/src/calibre/ebooks/conversion/plugins/txt_output.py index ef1b3dbad1..f250f08f01 100644 --- a/src/calibre/ebooks/conversion/plugins/txt_output.py +++ b/src/calibre/ebooks/conversion/plugins/txt_output.py @@ -127,9 +127,8 @@ class TXTZOutput(TXTOutput): file_type = 'txtz' def convert(self, oeb_book, output_path, input_plugin, opts, log): - from calibre.ebooks.oeb.base import OEB_IMAGES + from calibre.ebooks.oeb.base import OEB_IMAGES, xml2str from calibre.utils.zipfile import ZipFile - from lxml import etree with TemporaryDirectory('_txtz_output') as tdir: # TXT @@ -159,7 +158,7 @@ class TXTZOutput(TXTOutput): # Metadata with open(os.path.join(tdir, 'metadata.opf'), 'wb') as mdataf: - mdataf.write(etree.tostring(oeb_book.metadata.to_opf1())) + mdataf.write(xml2str(oeb_book.metadata.to_opf1(), pretty_print=True)) txtz = ZipFile(output_path, 'w') txtz.add_dir(tdir)