From ec11b0f42ac73a21efdc858ff537aa9c4de3b904 Mon Sep 17 00:00:00 2001 From: stefansli <104021830+stefansli@users.noreply.github.com> Date: Wed, 3 Apr 2024 18:08:42 +0200 Subject: [PATCH] Fix bug that only one reference per page is replaced --- src/autolink_references/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/autolink_references/main.py b/src/autolink_references/main.py index 4bf5cb0..e464f80 100755 --- a/src/autolink_references/main.py +++ b/src/autolink_references/main.py @@ -7,11 +7,11 @@ def replace_autolink_references(markdown, ref_prefix, target_url): if "" not in ref_prefix: ref_prefix = ref_prefix + "" find_regex = re.compile( - r"(?", r"(?P[-\w]+)") + r"(?", r"(?P[-\w]+)"), re.IGNORECASE ) linked_ref = rf"[{ref_prefix}](" + target_url + r")" replace_text = linked_ref.replace(r"", r"\g") - markdown = re.sub(find_regex, replace_text, markdown, re.IGNORECASE) + markdown = re.sub(find_regex, replace_text, markdown) return markdown