Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Whitespace and encoding declaration for epub files
  • Loading branch information
kthoden committed Jul 15, 2019
1 parent 729307a commit 94729c9
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions imxml2epub.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8; mode: python -*-
# Time-stamp: <2019-07-12 14:29:26 (kthoden)>
# Time-stamp: <2019-07-15 15:10:49 (kthoden)>

""" Convert a customized DocBook XML file into a set of files that
constitute the contents of an EPUB file.
Expand Down Expand Up @@ -417,8 +417,8 @@ def create_extra_font_css(css_selector, extrafontfiles):
}}
@font-face {{
font-family: "{font_label}";
src: url("fonts/{fontfile}");
font-family: "{font_label}";
src: url("fonts/{fontfile}");
}}
"""

Expand Down Expand Up @@ -1838,29 +1838,21 @@ class FootnoteError(Exception):
# Content_OPF hinzufügen
intTechnicalChapterNumber += 1

tmpFileName = OUTPUT_DIR / "OEBPS/toc.ncx"
tocncx_filename = OUTPUT_DIR / "OEBPS/toc.ncx"
logging.info("Saving toc.ncx")
tmpFile = open (tmpFileName, "w")
tmpResult = etree.tostring(tocncx, pretty_print=True, encoding="unicode")
tmpFile.write(tmpResult)
tmpFile.close()
tocncx.write( str(tocncx_filename), pretty_print=True, xml_declaration=True, encoding="utf-8")

contentopf_filename = OUTPUT_DIR / "OEBPS/content.opf"
logging.info("Saving content.opf")
tmpFileName = OUTPUT_DIR / "OEBPS/content.opf"
tmpFile = open (tmpFileName, "w")
tmpResult = etree.tostring(contentopf, pretty_print=True, encoding="unicode")
tmpFile.write(tmpResult)
tmpFile.close()
contentopf.write( str(contentopf_filename), pretty_print=True, xml_declaration=True, encoding="utf-8")

############################################################################
# Finishing various Stuff #
############################################################################

logging.info("Write Temporary XML-Tree")
ergebnisdatei = open(TEMP_DIR / "Devel_ebook.xml", "w")
ergebnis = etree.tostring(xmlEbookTree, pretty_print=True, encoding="unicode")
ergebnisdatei.write(ergebnis)
ergebnisdatei.close()
devel_ebook_file = TEMP_DIR / "Devel_ebook.xml"
logging.info(f"Write Temporary XML-Tree to {devel_ebook_file}.")
xmlEbookTree.write( str(devel_ebook_file), pretty_print=True, xml_declaration=True, encoding="utf-8")

if args.no_epub:
pass
Expand Down

0 comments on commit 94729c9

Please sign in to comment.