mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
Replace entities in economist JSON text
& seems to be used a lot
This commit is contained in:
parent
45513e0a1e
commit
bde48aa80d
@ -11,6 +11,7 @@ from collections import OrderedDict
|
|||||||
from html5_parser import parse
|
from html5_parser import parse
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
|
||||||
|
from calibre import replace_entities
|
||||||
from calibre.ebooks.BeautifulSoup import NavigableString, Tag
|
from calibre.ebooks.BeautifulSoup import NavigableString, Tag
|
||||||
from calibre.utils.cleantext import clean_ascii_chars
|
from calibre.utils.cleantext import clean_ascii_chars
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
@ -34,6 +35,7 @@ def process_node(node, html_parent):
|
|||||||
elif ntype == 'text':
|
elif ntype == 'text':
|
||||||
text = node.get('data')
|
text = node.get('data')
|
||||||
if text:
|
if text:
|
||||||
|
text = replace_entities(text)
|
||||||
if len(html_parent):
|
if len(html_parent):
|
||||||
t = html_parent[-1]
|
t = html_parent[-1]
|
||||||
t.tail = (t.tail or '') + text
|
t.tail = (t.tail or '') + text
|
||||||
|
@ -11,6 +11,7 @@ from collections import OrderedDict
|
|||||||
from html5_parser import parse
|
from html5_parser import parse
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
|
||||||
|
from calibre import replace_entities
|
||||||
from calibre.ebooks.BeautifulSoup import NavigableString, Tag
|
from calibre.ebooks.BeautifulSoup import NavigableString, Tag
|
||||||
from calibre.utils.cleantext import clean_ascii_chars
|
from calibre.utils.cleantext import clean_ascii_chars
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
@ -34,6 +35,7 @@ def process_node(node, html_parent):
|
|||||||
elif ntype == 'text':
|
elif ntype == 'text':
|
||||||
text = node.get('data')
|
text = node.get('data')
|
||||||
if text:
|
if text:
|
||||||
|
text = replace_entities(text)
|
||||||
if len(html_parent):
|
if len(html_parent):
|
||||||
t = html_parent[-1]
|
t = html_parent[-1]
|
||||||
t.tail = (t.tail or '') + text
|
t.tail = (t.tail or '') + text
|
||||||
|
Loading…
x
Reference in New Issue
Block a user