Replace entities in economist JSON text

& seems to be used a lot
This commit is contained in:
Kovid Goyal 2020-01-22 10:17:00 +05:30
parent 45513e0a1e
commit bde48aa80d
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 4 additions and 0 deletions

View File

@ -11,6 +11,7 @@ from collections import OrderedDict
from html5_parser import parse
from lxml import etree
from calibre import replace_entities
from calibre.ebooks.BeautifulSoup import NavigableString, Tag
from calibre.utils.cleantext import clean_ascii_chars
from calibre.web.feeds.news import BasicNewsRecipe
@ -34,6 +35,7 @@ def process_node(node, html_parent):
elif ntype == 'text':
text = node.get('data')
if text:
text = replace_entities(text)
if len(html_parent):
t = html_parent[-1]
t.tail = (t.tail or '') + text

View File

@ -11,6 +11,7 @@ from collections import OrderedDict
from html5_parser import parse
from lxml import etree
from calibre import replace_entities
from calibre.ebooks.BeautifulSoup import NavigableString, Tag
from calibre.utils.cleantext import clean_ascii_chars
from calibre.web.feeds.news import BasicNewsRecipe
@ -34,6 +35,7 @@ def process_node(node, html_parent):
elif ntype == 'text':
text = node.get('data')
if text:
text = replace_entities(text)
if len(html_parent):
t = html_parent[-1]
t.tail = (t.tail or '') + text