This commit is contained in:
Celogeek 2023-04-22 15:52:37 +02:00
parent 9cf733b553
commit e79cd346c4
Signed by: celogeek
SSH Key Fingerprint: SHA256:njNJLzoLQdbV9PC6ehcruRb0QnEgxABoCYZ+0+aUIYc

View File

@ -37,12 +37,18 @@ func (e *ePub) getToc(title string, images []*Image) string {
link := t.CreateElement("a")
link.CreateAttr("href", img.TextPath())
link.CreateText(path)
paths[currentPath] = t
paths[currentPath] = t.CreateElement("ol")
}
}
if len(ol.ChildElements()) == 1 && e.StripFirstDirectoryFromToc {
ol = ol.ChildElements()[0]
ol = ol.FindElement("/li/ol")
}
for _, v := range ol.FindElements("//ol") {
if len(v.ChildElements()) == 0 {
v.Parent().RemoveChild(v)
}
}
beginning := etree.NewElement("li")