mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Forgot to port getting text from serialized tree to new serialization format
This commit is contained in:
parent
6d8c3c3fbd
commit
47d3d16978
@ -394,18 +394,32 @@ def text_from_serialized_html(data):
|
|||||||
serialized_data = JSON.parse(data)
|
serialized_data = JSON.parse(data)
|
||||||
tag_map = serialized_data.tag_map
|
tag_map = serialized_data.tag_map
|
||||||
ans = v'[]'
|
ans = v'[]'
|
||||||
stack = v'[serialized_data.tree[2]]'
|
if tag_map:
|
||||||
|
stack = v'[serialized_data.tree[2]]'
|
||||||
|
else:
|
||||||
|
stack = v'[]'
|
||||||
|
for child in serialized_data.tree.c:
|
||||||
|
if child.n is 'body':
|
||||||
|
stack.push(child)
|
||||||
ignore_text = {'script':True, 'style':True}
|
ignore_text = {'script':True, 'style':True}
|
||||||
while stack.length:
|
while stack.length:
|
||||||
node = stack.pop()
|
node = stack.pop()
|
||||||
if jstype(node) is 'string':
|
if jstype(node) is 'string':
|
||||||
ans.push(node)
|
ans.push(node)
|
||||||
continue
|
continue
|
||||||
src = tag_map[node[0]]
|
if tag_map:
|
||||||
|
src = tag_map[node[0]]
|
||||||
|
else:
|
||||||
|
src = node
|
||||||
if not ignore_text[src.n] and src.x:
|
if not ignore_text[src.n] and src.x:
|
||||||
ans.push(src.x)
|
ans.push(src.x)
|
||||||
if src.l:
|
if src.l:
|
||||||
stack.push(src.l)
|
stack.push(src.l)
|
||||||
for v'var i = node.length - 1; i >= 1; i--':
|
if tag_map:
|
||||||
stack.push(node[i])
|
for v'var i = node.length - 1; i >= 1; i--':
|
||||||
|
stack.push(node[i])
|
||||||
|
else:
|
||||||
|
if src.c:
|
||||||
|
for v'var i = src.c.length; i-- > 0;':
|
||||||
|
stack.push(v'src.c[i]')
|
||||||
return ans.join('')
|
return ans.join('')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user