Skip to content

Commit

Permalink
non-numbered sections
Browse files Browse the repository at this point in the history
  • Loading branch information
kthoden committed Jan 14, 2020
1 parent 1c507db commit 221c479
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/imxml2epub.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 221c479

Please sign in to comment.