This commit is contained in:
John Schember 2009-11-21 20:48:35 -05:00
parent fb7ecb5cf2
commit 2bdc1afa25
2 changed files with 4 additions and 10 deletions

View File

@ -31,5 +31,5 @@ class Reader(FormatReader):
def dump_pml(self): def dump_pml(self):
return self.reader.dump_pml() return self.reader.dump_pml()
def dump_images(self): def dump_images(self, out_dir):
return self.reader.dump_images() return self.reader.dump_images(out_dir)

View File

@ -10,16 +10,10 @@ __docformat__ = 'restructuredtext en'
import re import re
from calibre import my_unichr from calibre import my_unichr, prepare_string_for_xml
from calibre.ebooks.pdb.ereader import image_name from calibre.ebooks.pdb.ereader import image_name
PML_HTML_RULES = [ PML_HTML_RULES = [
# Any literal <, &, and > chars be escaped to avoid HTML issues (though
# <footnote> and <sidebar> tags are handled specially later).
(re.compile(r'&'), lambda match: '&amp;'),
(re.compile(r'<'), lambda match: '&lt;'),
(re.compile(r'>'), lambda match: '&gt;'),
# NOP-process all \x escapes, turning \\ into &#92; This keeps the regex # NOP-process all \x escapes, turning \\ into &#92; This keeps the regex
# parsing simple while making sure that we don't try to honor \\x as \x # parsing simple while making sure that we don't try to honor \\x as \x
# (and also makes sure we DO honor \\\x as &#92; followed by \x). # (and also makes sure we DO honor \\\x as &#92; followed by \x).
@ -83,7 +77,7 @@ PML_HTML_RULES = [
] ]
def pml_to_html(pml): def pml_to_html(pml):
html = pml html = prepare_string_for_xml(pml)
for rule in PML_HTML_RULES: for rule in PML_HTML_RULES:
html = rule[0].sub(rule[1], html) html = rule[0].sub(rule[1], html)