Workaround the Economists new usage of a custom font for small caps text

This commit is contained in:
Kovid Goyal 2022-05-28 15:38:22 +05:30
parent 6a30220c8f
commit b815560dd1
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 12 additions and 0 deletions

View File

@ -220,6 +220,12 @@ class Economist(BasicNewsRecipe):
p.remove(noscript[0]) p.remove(noscript[0])
for x in root.xpath('//*[name()="script" or name()="style" or name()="source" or name()="meta"]'): for x in root.xpath('//*[name()="script" or name()="style" or name()="source" or name()="meta"]'):
x.getparent().remove(x) x.getparent().remove(x)
# the economist uses <small> for small caps with a custom font
for x in root.xpath('//small'):
if x.text and len(x.text.split()) == 1 and len(x) == 0:
x.text = x.text.upper()
x.tag = 'span'
x.set('style', 'font-variant: small-caps')
raw = etree.tostring(root, encoding='unicode') raw = etree.tostring(root, encoding='unicode')
return raw return raw

View File

@ -220,6 +220,12 @@ class Economist(BasicNewsRecipe):
p.remove(noscript[0]) p.remove(noscript[0])
for x in root.xpath('//*[name()="script" or name()="style" or name()="source" or name()="meta"]'): for x in root.xpath('//*[name()="script" or name()="style" or name()="source" or name()="meta"]'):
x.getparent().remove(x) x.getparent().remove(x)
# the economist uses <small> for small caps with a custom font
for x in root.xpath('//small'):
if x.text and len(x.text.split()) == 1 and len(x) == 0:
x.text = x.text.upper()
x.tag = 'span'
x.set('style', 'font-variant: small-caps')
raw = etree.tostring(root, encoding='unicode') raw = etree.tostring(root, encoding='unicode')
return raw return raw