From bf53465ad55e4f36ff60a9b525bc67f00cd8b370 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Mon, 1 Jul 2024 23:19:08 -0400 Subject: [PATCH] Make contributor records to be hyperlink if email or URL email matching is quite rudimentary but I think should work here. Note: did not test if works, mostly chatgpt creation ;-) --- databook_utils/insert_authors_version.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/databook_utils/insert_authors_version.py b/databook_utils/insert_authors_version.py index 6e99b1a1..01a90e9e 100644 --- a/databook_utils/insert_authors_version.py +++ b/databook_utils/insert_authors_version.py @@ -133,7 +133,16 @@ def run(self): line_block = nodes.line_block() for property in properties[1:]: - if property != "": + if not property: + continue + elif property.startswith("https://") or property.startswith("http://"): + link_node = nodes.reference(text=property, refuri=property) + line_block.append(link_node) + elif "@" in property: + mailto_link = f"mailto:{property}" + email_node = nodes.reference(text=property, refuri=mailto_link) + line_block.append(email_node) + else: line_block.append(nodes.line(text=property)) line_block.append(nodes.line(text="")) @@ -153,4 +162,4 @@ def setup(app): 'version': '0.1', 'parallel_read_safe': True, 'parallel_write_safe': True, - } \ No newline at end of file + }