From f89d0efa1f216018aeab84be2be53ab15012e41a Mon Sep 17 00:00:00 2001 From: John Schember Date: Mon, 4 Apr 2011 19:47:59 -0400 Subject: [PATCH] HTMLZ Output: Use urldefrag instead of doing it ourself. --- src/calibre/ebooks/htmlz/oeb2html.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/calibre/ebooks/htmlz/oeb2html.py b/src/calibre/ebooks/htmlz/oeb2html.py index 827e57b932..af5867356a 100644 --- a/src/calibre/ebooks/htmlz/oeb2html.py +++ b/src/calibre/ebooks/htmlz/oeb2html.py @@ -12,7 +12,7 @@ Transform OEB content into a single (more or less) HTML file. import os -from urlparse import urlparse +from urlparse import urlparse, urldefrag from calibre import prepare_string_for_xml from calibre.ebooks.oeb.base import XHTML, XHTML_NS, barename, namespace @@ -70,9 +70,7 @@ class OEB2HTML(object): if tag == 'a': href = page.abshref(attribs['href']) if self.url_is_relative(href): - id = '' - if '#' in href: - href, n, id = href.partition('#') + href, id = urldefrag(href) href = '#%s' % self.get_link_id(href, id) attribs['href'] = href return attribs