From 674615e1d0cce1db3faacc945370684d37adc7d3 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 26 May 2018 08:14:47 +0530 Subject: [PATCH] Edit book: Fix a regression in the previous release that broke syncing between the editor and the Preview panel/Live CSS panel. Fixes #1773424 [Editor : preview panel](https://bugs.launchpad.net/calibre/+bug/1773424) --- src/calibre/ebooks/oeb/polish/parsing.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/oeb/polish/parsing.py b/src/calibre/ebooks/oeb/polish/parsing.py index 20f4065839..e89275393c 100644 --- a/src/calibre/ebooks/oeb/polish/parsing.py +++ b/src/calibre/ebooks/oeb/polish/parsing.py @@ -52,7 +52,7 @@ def handle_private_entities(data): idx = data.find(' -1: pre = data[:idx] - data = data[idx:] + num_of_nl_in_pre = pre.count('\n') if ']+)', pre): @@ -61,6 +61,7 @@ def handle_private_entities(data): val = val[1:-1] user_entities[match.group(1)] = val if user_entities: + data = ('\n' * num_of_nl_in_pre) + data[idx:] pat = re.compile(r'&(%s);'%('|'.join(user_entities.keys()))) data = pat.sub(lambda m:user_entities[m.group(1)], data) return data