diff --git a/recipes/economist.recipe b/recipes/economist.recipe
index eb904f34e2..733dd03652 100644
--- a/recipes/economist.recipe
+++ b/recipes/economist.recipe
@@ -44,7 +44,12 @@ def process_info_box(bx):
def parse_txt(ty):
typ = ty.get('type', '')
children = ty.get('children', [])
- attr = ty.get('attributes', [{}])[0].get('value', '#')
+ href = '#'
+ attributes = ty.get('attributes') or ()
+ for a in attributes:
+ if a.get('name') == 'href':
+ href = a.get('value', href)
+ break
tag_map = {
'text': lambda: [ty.get('value', '')],
@@ -57,12 +62,12 @@ def parse_txt(ty):
'italic': lambda: [f'{"".join(parse_txt(c))}' for c in children],
'linebreak': lambda: ['
'],
'external_link': lambda: [
- f'{"".join(parse_txt(children[0]))}'
+ f'{"".join(parse_txt(children[0]))}'
]
if children
else [],
'internal_link': lambda: [
- f'{"".join(parse_txt(children[0]))}'
+ f'{"".join(parse_txt(children[0]))}'
]
if children
else [],
diff --git a/recipes/economist_free.recipe b/recipes/economist_free.recipe
index eb904f34e2..733dd03652 100644
--- a/recipes/economist_free.recipe
+++ b/recipes/economist_free.recipe
@@ -44,7 +44,12 @@ def process_info_box(bx):
def parse_txt(ty):
typ = ty.get('type', '')
children = ty.get('children', [])
- attr = ty.get('attributes', [{}])[0].get('value', '#')
+ href = '#'
+ attributes = ty.get('attributes') or ()
+ for a in attributes:
+ if a.get('name') == 'href':
+ href = a.get('value', href)
+ break
tag_map = {
'text': lambda: [ty.get('value', '')],
@@ -57,12 +62,12 @@ def parse_txt(ty):
'italic': lambda: [f'{"".join(parse_txt(c))}' for c in children],
'linebreak': lambda: ['
'],
'external_link': lambda: [
- f'{"".join(parse_txt(children[0]))}'
+ f'{"".join(parse_txt(children[0]))}'
]
if children
else [],
'internal_link': lambda: [
- f'{"".join(parse_txt(children[0]))}'
+ f'{"".join(parse_txt(children[0]))}'
]
if children
else [],