From c385f4dc68b58fb56213f77f59b2367da62889fe Mon Sep 17 00:00:00 2001 From: Ward Poelmans Date: Tue, 23 Apr 2024 13:28:22 +0200 Subject: [PATCH] properly log error with failed regex --- src/term_rst_post/__init__.py | 2 +- src/term_rst_post/newspost.py | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/term_rst_post/__init__.py b/src/term_rst_post/__init__.py index 6af6b73..c1e2099 100644 --- a/src/term_rst_post/__init__.py +++ b/src/term_rst_post/__init__.py @@ -29,4 +29,4 @@ @author: Alex Domingo (Vrije Universiteit Brussel) """ -__version__ = "1.2.2" +__version__ = "1.2.3" diff --git a/src/term_rst_post/newspost.py b/src/term_rst_post/newspost.py index 15a33ca..9cd3ce4 100644 --- a/src/term_rst_post/newspost.py +++ b/src/term_rst_post/newspost.py @@ -384,10 +384,12 @@ def plain_ref_role(name, rawtext, text, lineno, inliner, options={}, content=[]) Targets of :ref: are internal labels without meaning that should be hidden """ text = utils.unescape(text) - regex = re.compile("(.*?)\s*\<(.*?)\>") - match = regex.match(text) - label = match.group(1) - target = match.group(2) + regex = re.compile(r"(.*?)\s*\<(.*?)\>") + try: + match = regex.match(text) + label = match.group(1) + except AttributeError as err: + error_exit(f"Failed to extract label from '{text}'", err) node = nodes.inline() node += nodes.Text(label)