Add links in text.

This commit is contained in:
Sergio Martínez Portela 2022-05-06 15:58:28 +02:00
parent 09cfed5fdd
commit c86ec3fc9b

View File

@ -7,7 +7,7 @@ import sys
import uuid import uuid
from datetime import datetime 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 dump as dump_org
from org_rw import load as load_org from org_rw import load as load_org
from org_rw import token_list_to_raw from org_rw import token_list_to_raw
@ -137,8 +137,14 @@ def render_code_block(element, acc):
def render_text(element, acc): def render_text(element, acc):
for chunk in element.content.contents: for chunk in element.content:
if isinstance(chunk, str):
acc.append('<span class="text">{}</span> '.format(chunk)) acc.append('<span class="text">{}</span> '.format(chunk))
elif isinstance(chunk, Link):
# @TODO: URLEscape
acc.append('<a href="{}">{}</a>'.format(chunk.value, chunk.description))
else:
raise NotImplemented()
def render_tag(element, acc): def render_tag(element, acc):