diff --git a/src/calibre/ebooks/conversion/plugins/html_output.py b/src/calibre/ebooks/conversion/plugins/html_output.py index 7e732015c6..4ea5f630e4 100644 --- a/src/calibre/ebooks/conversion/plugins/html_output.py +++ b/src/calibre/ebooks/conversion/plugins/html_output.py @@ -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')