diff --git a/recipes/1843.recipe b/recipes/1843.recipe index 3ad6cdf29d..7cd9dfc023 100644 --- a/recipes/1843.recipe +++ b/recipes/1843.recipe @@ -30,7 +30,7 @@ def process_web_list(li_node): li_html += f'
  • {parse_textjson(li["textJson"])}
  • ' else: li_html += f'
  • {li.get("text", "")}
  • ' - return li_html + return '' def process_info_box(bx): @@ -43,7 +43,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', '')], @@ -56,12 +61,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_news.recipe b/recipes/economist_news.recipe index 4d87211ece..ae93fbebe7 100644 --- a/recipes/economist_news.recipe +++ b/recipes/economist_news.recipe @@ -32,7 +32,7 @@ def process_web_list(li_node): li_html += f'
  • {parse_textjson(li["textJson"])}
  • ' else: li_html += f'
  • {li.get("text", "")}
  • ' - return li_html + return '' def process_info_box(bx): @@ -45,7 +45,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', '')], @@ -58,12 +63,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_search.recipe b/recipes/economist_search.recipe index 1eb7f81b68..5c3fb32790 100644 --- a/recipes/economist_search.recipe +++ b/recipes/economist_search.recipe @@ -30,7 +30,7 @@ def process_web_list(li_node): li_html += f'
  • {parse_textjson(li["textJson"])}
  • ' else: li_html += f'
  • {li.get("text", "")}
  • ' - return li_html + return '' def process_info_box(bx): @@ -43,7 +43,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', '')], @@ -56,12 +61,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_world_ahead.recipe b/recipes/economist_world_ahead.recipe index 1dde240a18..369066d1ac 100644 --- a/recipes/economist_world_ahead.recipe +++ b/recipes/economist_world_ahead.recipe @@ -31,7 +31,7 @@ def process_web_list(li_node): li_html += f'
  • {parse_textjson(li["textJson"])}
  • ' else: li_html += f'
  • {li.get("text", "")}
  • ' - return li_html + return '' def process_info_box(bx): @@ -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 [],