From b815560dd1d542015a2e4415541affdaf0992589 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 28 May 2022 15:38:22 +0530 Subject: [PATCH] Workaround the Economists new usage of a custom font for small caps text --- recipes/economist.recipe | 6 ++++++ recipes/economist_free.recipe | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/recipes/economist.recipe b/recipes/economist.recipe index 651739e50e..6b3c1084b2 100644 --- a/recipes/economist.recipe +++ b/recipes/economist.recipe @@ -220,6 +220,12 @@ class Economist(BasicNewsRecipe): p.remove(noscript[0]) for x in root.xpath('//*[name()="script" or name()="style" or name()="source" or name()="meta"]'): x.getparent().remove(x) + # the economist uses 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') return raw diff --git a/recipes/economist_free.recipe b/recipes/economist_free.recipe index 651739e50e..6b3c1084b2 100644 --- a/recipes/economist_free.recipe +++ b/recipes/economist_free.recipe @@ -220,6 +220,12 @@ class Economist(BasicNewsRecipe): p.remove(noscript[0]) for x in root.xpath('//*[name()="script" or name()="style" or name()="source" or name()="meta"]'): x.getparent().remove(x) + # the economist uses 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') return raw