mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
commit
e89c1392a1
@ -384,6 +384,15 @@ def entity_to_unicode(match, exceptions=[], encoding='cp1252'):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
return '&'+ent+';'
|
return '&'+ent+';'
|
||||||
|
|
||||||
|
_ent_pat = re.compile(r'&(\S+);')
|
||||||
|
|
||||||
|
def prepare_string_for_xml(raw, attribute=False):
|
||||||
|
raw = _ent_pat.sub(entity_to_unicode, raw)
|
||||||
|
raw = raw.replace('&', '&').replace('<', '<').replace('>', '>')
|
||||||
|
if attribute:
|
||||||
|
raw = raw.replace('"', '"').replace("'", ''')
|
||||||
|
return raw
|
||||||
|
|
||||||
if isosx:
|
if isosx:
|
||||||
fdir = os.path.expanduser('~/.fonts')
|
fdir = os.path.expanduser('~/.fonts')
|
||||||
try:
|
try:
|
||||||
|
@ -12,7 +12,7 @@ from urllib import unquote
|
|||||||
from calibre.customize.conversion import OutputFormatPlugin
|
from calibre.customize.conversion import OutputFormatPlugin
|
||||||
from calibre.ptempfile import TemporaryDirectory
|
from calibre.ptempfile import TemporaryDirectory
|
||||||
from calibre.constants import __appname__, __version__
|
from calibre.constants import __appname__, __version__
|
||||||
from calibre import strftime, guess_type
|
from calibre import strftime, guess_type, prepare_string_for_xml
|
||||||
from calibre.customize.conversion import OptionRecommendation
|
from calibre.customize.conversion import OptionRecommendation
|
||||||
|
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
@ -210,6 +210,7 @@ class EPUBOutput(OutputFormatPlugin):
|
|||||||
id, href = self.oeb.manifest.generate('calibre-logo',
|
id, href = self.oeb.manifest.generate('calibre-logo',
|
||||||
'calibre-logo.png')
|
'calibre-logo.png')
|
||||||
self.oeb.manifest.add(id, href, 'image/png', data=img_data)
|
self.oeb.manifest.add(id, href, 'image/png', data=img_data)
|
||||||
|
title, author = map(prepare_string_for_xml, (title, author))
|
||||||
html = self.TITLEPAGE%dict(title=title, author=author,
|
html = self.TITLEPAGE%dict(title=title, author=author,
|
||||||
date=strftime('%d %b, %Y'),
|
date=strftime('%d %b, %Y'),
|
||||||
app=__appname__ +' '+__version__,
|
app=__appname__ +' '+__version__,
|
||||||
|
@ -301,30 +301,26 @@ class FlowSplitter(object):
|
|||||||
|
|
||||||
# Tree 1
|
# Tree 1
|
||||||
hit_split_point = False
|
hit_split_point = False
|
||||||
for elem in list(body.iterdescendants(etree.Element)):
|
for elem in list(body.iterdescendants()):
|
||||||
if elem is split_point:
|
if elem is split_point:
|
||||||
hit_split_point = True
|
hit_split_point = True
|
||||||
if before:
|
if before:
|
||||||
x = elem.get('id', None)
|
|
||||||
nix_element(elem)
|
nix_element(elem)
|
||||||
|
|
||||||
continue
|
continue
|
||||||
if hit_split_point:
|
if hit_split_point:
|
||||||
x = elem.get('id', None)
|
|
||||||
nix_element(elem)
|
nix_element(elem)
|
||||||
|
|
||||||
|
|
||||||
# Tree 2
|
# Tree 2
|
||||||
hit_split_point = False
|
hit_split_point = False
|
||||||
for elem in list(body2.iterdescendants(etree.Element)):
|
for elem in list(body2.iterdescendants()):
|
||||||
if elem is split_point2:
|
if elem is split_point2:
|
||||||
hit_split_point = True
|
hit_split_point = True
|
||||||
if not before:
|
if not before:
|
||||||
x = elem.get('id', None)
|
|
||||||
nix_element(elem, top=False)
|
nix_element(elem, top=False)
|
||||||
continue
|
continue
|
||||||
if not hit_split_point:
|
if not hit_split_point:
|
||||||
x = elem.get('id', None)
|
|
||||||
nix_element(elem, top=False)
|
nix_element(elem, top=False)
|
||||||
body2.text = '\n'
|
body2.text = '\n'
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user