mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix for HTMLZ not converting necessary characters to entities.
This commit is contained in:
parent
2222ecca21
commit
472e8d1743
@ -126,6 +126,14 @@ class OEB2HTML(object):
|
|||||||
css = item.data.cssText
|
css = item.data.cssText
|
||||||
break
|
break
|
||||||
return css
|
return css
|
||||||
|
|
||||||
|
def prepare_string_for_html(self, raw):
|
||||||
|
raw = prepare_string_for_xml(raw)
|
||||||
|
raw = raw.replace(u'\u00ad', '­')
|
||||||
|
raw = raw.replace(u'\u2014', '—')
|
||||||
|
raw = raw.replace(u'\u2013', '–')
|
||||||
|
raw = raw.replace(u'\u00a0', ' ')
|
||||||
|
return raw
|
||||||
|
|
||||||
|
|
||||||
class OEB2HTMLNoCSSizer(OEB2HTML):
|
class OEB2HTMLNoCSSizer(OEB2HTML):
|
||||||
@ -194,7 +202,7 @@ class OEB2HTMLNoCSSizer(OEB2HTML):
|
|||||||
|
|
||||||
# Process tags that contain text.
|
# Process tags that contain text.
|
||||||
if hasattr(elem, 'text') and elem.text:
|
if hasattr(elem, 'text') and elem.text:
|
||||||
text.append(elem.text)
|
text.append(self.prepare_string_for_html(elem.text))
|
||||||
|
|
||||||
# Recurse down into tags within the tag we are in.
|
# Recurse down into tags within the tag we are in.
|
||||||
for item in elem:
|
for item in elem:
|
||||||
@ -207,7 +215,7 @@ class OEB2HTMLNoCSSizer(OEB2HTML):
|
|||||||
|
|
||||||
# Add the text that is outside of the tag.
|
# Add the text that is outside of the tag.
|
||||||
if hasattr(elem, 'tail') and elem.tail:
|
if hasattr(elem, 'tail') and elem.tail:
|
||||||
text.append(elem.tail)
|
text.append(self.prepare_string_for_html(elem.tail))
|
||||||
|
|
||||||
return text
|
return text
|
||||||
|
|
||||||
@ -267,7 +275,7 @@ class OEB2HTMLInlineCSSizer(OEB2HTML):
|
|||||||
|
|
||||||
# Process tags that contain text.
|
# Process tags that contain text.
|
||||||
if hasattr(elem, 'text') and elem.text:
|
if hasattr(elem, 'text') and elem.text:
|
||||||
text.append(elem.text)
|
text.append(self.prepare_string_for_html(elem.text))
|
||||||
|
|
||||||
# Recurse down into tags within the tag we are in.
|
# Recurse down into tags within the tag we are in.
|
||||||
for item in elem:
|
for item in elem:
|
||||||
@ -280,7 +288,7 @@ class OEB2HTMLInlineCSSizer(OEB2HTML):
|
|||||||
|
|
||||||
# Add the text that is outside of the tag.
|
# Add the text that is outside of the tag.
|
||||||
if hasattr(elem, 'tail') and elem.tail:
|
if hasattr(elem, 'tail') and elem.tail:
|
||||||
text.append(elem.tail)
|
text.append(self.prepare_string_for_html(elem.tail))
|
||||||
|
|
||||||
return text
|
return text
|
||||||
|
|
||||||
@ -347,7 +355,7 @@ class OEB2HTMLClassCSSizer(OEB2HTML):
|
|||||||
|
|
||||||
# Process tags that contain text.
|
# Process tags that contain text.
|
||||||
if hasattr(elem, 'text') and elem.text:
|
if hasattr(elem, 'text') and elem.text:
|
||||||
text.append(elem.text)
|
text.append(self.prepare_string_for_html(elem.text))
|
||||||
|
|
||||||
# Recurse down into tags within the tag we are in.
|
# Recurse down into tags within the tag we are in.
|
||||||
for item in elem:
|
for item in elem:
|
||||||
@ -360,7 +368,7 @@ class OEB2HTMLClassCSSizer(OEB2HTML):
|
|||||||
|
|
||||||
# Add the text that is outside of the tag.
|
# Add the text that is outside of the tag.
|
||||||
if hasattr(elem, 'tail') and elem.tail:
|
if hasattr(elem, 'tail') and elem.tail:
|
||||||
text.append(elem.tail)
|
text.append(self.prepare_string_for_html(elem.tail))
|
||||||
|
|
||||||
return text
|
return text
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user