From 4604cff47a0af17e8cdff6c2e1fe6a6274e2f328 Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Fri, 2 Aug 2024 01:45:43 -0400 Subject: Only render emotes that exist. --- utils/mistune_emote.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'utils') diff --git a/utils/mistune_emote.py b/utils/mistune_emote.py index 6c557a5..9ca6f11 100644 --- a/utils/mistune_emote.py +++ b/utils/mistune_emote.py @@ -1,5 +1,6 @@ # Chris Xiong 2024 # License: Expat (MIT) +import os from config import conf EMOTE_PATTERN = r":(?!\s)(?P.+?)(?!\s):" @@ -13,7 +14,10 @@ def parse_inline_emote(inline, m, state): return m.end() def render_inline_emote(renderer, ename): - return f'{ename}' + if os.path.isfile(os.path.join(conf.LOCAL_DATA_ROOT, os.path.join("emotes", f"{ename}{emote_extension}"))): + return f'{ename}' + else: + return f":{ename}:" def emote(md): md.inline.register("inline_emote", EMOTE_PATTERN, parse_inline_emote, before="link") -- cgit v1.2.3