diff --git a/src/imxml2epub.py b/src/imxml2epub.py index 0e9b316..55c3385 100755 --- a/src/imxml2epub.py +++ b/src/imxml2epub.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -*- coding: utf-8; mode: python -*- -# Time-stamp: <2020-01-14 14:56:34 (kthoden)> +# Time-stamp: <2020-01-14 16:18:28 (kthoden)> """ Convert a customized DocBook XML file into a set of files that constitute the contents of an EPUB file. @@ -721,21 +721,25 @@ def add_css_snippet(css_snippet, css_file): xmlSections = xmlEbookTree.findall(".//div2") for xmlSection in xmlSections: xmlSection.find("head").tag = "h2" - if xmlSection.get("rend") != "nonumber": - idSection = xmlSection.get("id") - strHeadline = xmlSection.find("h2").text or "" - logging.info(strHeadline) + idSection = xmlSection.get("id") + strHeadline = xmlSection.find("h2").text or "" + logging.info(strHeadline) + if xmlSection.get("n") != "nonumber": xmlSection.find("h2").text = str(dictSections[idSection]) + " " + strHeadline + else: + xmlSection.find("h2").text = strHeadline logging.info(f"{logseparator}Convert EOAsubsection to H3") xmlSubsections = xmlEbookTree.findall(".//div3") for xmlSubsection in xmlSubsections: xmlSubsection.find("head").tag = "h3" - if xmlSubsection.get("rend") != "nonumber": - idSection = xmlSubsection.get("id") - strHeadline = xmlSubsection.find("h3").text or "" - logging.info(strHeadline) + idSection = xmlSubsection.get("id") + strHeadline = xmlSubsection.find("h3").text or "" + logging.info(strHeadline) + if xmlSubsection.get("n") != "nonumber": xmlSubsection.find("h3").text = str(dictSections[idSection]) + " " + strHeadline + else: + xmlSubsection.find("h3").text = strHeadline logging.info(f"{logseparator}Convert EOAsubsubsection to H4") xmlSubsubsections = xmlEbookTree.findall(".//div4")