mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 02:34:06 -04:00
MOBI metadata: Replace HTML entities in the title read from the MOBI file
This commit is contained in:
parent
9825a47254
commit
a1cf7ebe59
@ -440,6 +440,9 @@ xml_entity_to_unicode = partial(entity_to_unicode, result_exceptions = {
|
|||||||
'>' : '>',
|
'>' : '>',
|
||||||
'&' : '&'})
|
'&' : '&'})
|
||||||
|
|
||||||
|
def replace_entities(raw):
|
||||||
|
return _ent_pat.sub(entity_to_unicode, raw)
|
||||||
|
|
||||||
def prepare_string_for_xml(raw, attribute=False):
|
def prepare_string_for_xml(raw, attribute=False):
|
||||||
raw = _ent_pat.sub(entity_to_unicode, raw)
|
raw = _ent_pat.sub(entity_to_unicode, raw)
|
||||||
raw = raw.replace('&', '&').replace('<', '<').replace('>', '>')
|
raw = raw.replace('&', '&').replace('<', '<').replace('>', '>')
|
||||||
|
@ -14,7 +14,8 @@ except ImportError:
|
|||||||
|
|
||||||
from lxml import html, etree
|
from lxml import html, etree
|
||||||
|
|
||||||
from calibre import xml_entity_to_unicode, CurrentDir, entity_to_unicode
|
from calibre import xml_entity_to_unicode, CurrentDir, entity_to_unicode, \
|
||||||
|
replace_entities
|
||||||
from calibre.utils.filenames import ascii_filename
|
from calibre.utils.filenames import ascii_filename
|
||||||
from calibre.utils.date import parse_date
|
from calibre.utils.date import parse_date
|
||||||
from calibre.ptempfile import TemporaryDirectory
|
from calibre.ptempfile import TemporaryDirectory
|
||||||
@ -70,7 +71,7 @@ class EXTHHeader(object):
|
|||||||
#else:
|
#else:
|
||||||
# print 'unknown record', id, repr(content)
|
# print 'unknown record', id, repr(content)
|
||||||
if title:
|
if title:
|
||||||
self.mi.title = title
|
self.mi.title = replace_entities(title)
|
||||||
|
|
||||||
def process_metadata(self, id, content, codec):
|
def process_metadata(self, id, content, codec):
|
||||||
if id == 100:
|
if id == 100:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user