From ff5490e87fa92af3a01f186c61ea5ba169a663b4 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 11 Jul 2009 16:57:20 -0600 Subject: [PATCH] Fix #2537 (User-defined entities not processed) --- src/calibre/ebooks/oeb/base.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/calibre/ebooks/oeb/base.py b/src/calibre/ebooks/oeb/base.py index 618e28daeb..8d51f4c6af 100644 --- a/src/calibre/ebooks/oeb/base.py +++ b/src/calibre/ebooks/oeb/base.py @@ -770,7 +770,18 @@ class Manifest(object): # declarations, which messes up the coesrcing logic idx = data.find(' -1: + pre = data[:idx] data = data[idx:] + if ']+)', pre): + val = match.group(2) + if val.startswith('"') and val.endswith('"'): + val = val[1:-1] + user_entities[match.group(1)] = val + if user_entities: + pat = re.compile(r'&(%s);'%('|'.join(user_entities.keys()))) + data = pat.sub(lambda m:user_entities[m.group(1)], data) # Try with more & more drastic measures to parse def first_pass(data):