mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
ZIP Output: Fix an error when building the ToC on macOS for some books with non-ASCII ToC entries
Fixes #1813905 [ebook convert successfully in GUI but failed in command line](https://bugs.launchpad.net/calibre/+bug/1813905) [ebook convert successfully in GUI but failed in command line](https://bugs.launchpad.net/calibre/+bug/1813905)
This commit is contained in:
parent
4590d36660
commit
9ef0060c33
@ -49,6 +49,7 @@ class HTMLOutput(OutputFormatPlugin):
|
||||
from urllib import unquote
|
||||
|
||||
from calibre.ebooks.oeb.base import element
|
||||
from calibre.utils.cleantext import clean_xml_chars
|
||||
with CurrentDir(output_dir):
|
||||
def build_node(current_node, parent=None):
|
||||
if parent is None:
|
||||
@ -58,11 +59,15 @@ class HTMLOutput(OutputFormatPlugin):
|
||||
for node in current_node.nodes:
|
||||
point = element(parent, 'li')
|
||||
href = relpath(abspath(unquote(node.href)), dirname(ref_url))
|
||||
link = element(point, 'a', href=href)
|
||||
if isinstance(href, bytes):
|
||||
href = href.decode('utf-8')
|
||||
link = element(point, 'a', href=clean_xml_chars(href))
|
||||
title = node.title
|
||||
if isinstance(title, bytes):
|
||||
title = title.decode('utf-8')
|
||||
if title:
|
||||
title = re.sub(r'\s+', ' ', title)
|
||||
link.text=title
|
||||
link.text = clean_xml_chars(title)
|
||||
build_node(node, point)
|
||||
return parent
|
||||
wrap = etree.Element('div')
|
||||
|
Loading…
x
Reference in New Issue
Block a user