aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Hassan Abouelela <[email protected]>2022-08-13 21:54:46 +0200
committerGravatar Hassan Abouelela <[email protected]>2022-08-13 21:54:46 +0200
commit74226511e22f04ae5a0f0975849469ad027dc963 (patch)
treec114ba57baabdcaec8da9db7d333a61791a880c2
parentSet Link Color For Sub-elements (diff)
Clean Up Tag Link Substitution
Co-authored-by: ChrisJL <[email protected]> Signed-off-by: Hassan Abouelela <[email protected]>
-rw-r--r--pydis_site/apps/content/views/tags.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/pydis_site/apps/content/views/tags.py b/pydis_site/apps/content/views/tags.py
index e2cfb488..5295537d 100644
--- a/pydis_site/apps/content/views/tags.py
+++ b/pydis_site/apps/content/views/tags.py
@@ -31,11 +31,10 @@ class TagView(TemplateView):
content = body[1]
# Check for tags which can be hyperlinked
- start = 0
- while match := COMMAND_REGEX.search(content, start):
+ def sub(match: re.Match) -> str:
link = reverse("content:tag", kwargs={"name": match.group("name")})
- content = content[:match.start()] + f"[{match.group()}]({link})" + content[match.end():]
- start = match.end()
+ return f"[{match.group()}]({link})"
+ content = COMMAND_REGEX.sub(sub, content)
# Add support for some embed elements
if embed := body[0].get("embed"):