From c86ec3fc9b2998025dc8020ad33536e9c0bb8b56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Mart=C3=ADnez=20Portela?= Date: Fri, 6 May 2022 15:58:28 +0200 Subject: [PATCH] Add links in text. --- _scripts/generate.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/_scripts/generate.py b/_scripts/generate.py index 731ed29..557f5d8 100644 --- a/_scripts/generate.py +++ b/_scripts/generate.py @@ -7,7 +7,7 @@ import sys import uuid from datetime import datetime -from org_rw import OrgTime, dom +from org_rw import OrgTime, dom, Link from org_rw import dump as dump_org from org_rw import load as load_org from org_rw import token_list_to_raw @@ -137,8 +137,14 @@ def render_code_block(element, acc): def render_text(element, acc): - for chunk in element.content.contents: - acc.append('{} '.format(chunk)) + for chunk in element.content: + if isinstance(chunk, str): + acc.append('{} '.format(chunk)) + elif isinstance(chunk, Link): + # @TODO: URLEscape + acc.append('{}'.format(chunk.value, chunk.description)) + else: + raise NotImplemented() def render_tag(element, acc):