mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
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)
This commit is contained in:
parent
8785bab5f7
commit
674615e1d0
@ -52,7 +52,7 @@ def handle_private_entities(data):
|
|||||||
idx = data.find('<HTML')
|
idx = data.find('<HTML')
|
||||||
if idx > -1:
|
if idx > -1:
|
||||||
pre = data[:idx]
|
pre = data[:idx]
|
||||||
data = data[idx:]
|
num_of_nl_in_pre = pre.count('\n')
|
||||||
if '<!DOCTYPE' in pre: # Handle user defined entities
|
if '<!DOCTYPE' in pre: # Handle user defined entities
|
||||||
user_entities = {}
|
user_entities = {}
|
||||||
for match in re.finditer(r'<!ENTITY\s+(\S+)\s+([^>]+)', pre):
|
for match in re.finditer(r'<!ENTITY\s+(\S+)\s+([^>]+)', pre):
|
||||||
@ -61,6 +61,7 @@ def handle_private_entities(data):
|
|||||||
val = val[1:-1]
|
val = val[1:-1]
|
||||||
user_entities[match.group(1)] = val
|
user_entities[match.group(1)] = val
|
||||||
if user_entities:
|
if user_entities:
|
||||||
|
data = ('\n' * num_of_nl_in_pre) + data[idx:]
|
||||||
pat = re.compile(r'&(%s);'%('|'.join(user_entities.keys())))
|
pat = re.compile(r'&(%s);'%('|'.join(user_entities.keys())))
|
||||||
data = pat.sub(lambda m:user_entities[m.group(1)], data)
|
data = pat.sub(lambda m:user_entities[m.group(1)], data)
|
||||||
return data
|
return data
|
||||||
|
Loading…
x
Reference in New Issue
Block a user