From 286f7303be0d81a075a82f7ad0dc501e90633b4b Mon Sep 17 00:00:00 2001 From: binary-husky Date: Sun, 12 Jan 2025 21:54:43 +0800 Subject: [PATCH] fix image display bug --- shared_utils/advanced_markdown_format.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/shared_utils/advanced_markdown_format.py b/shared_utils/advanced_markdown_format.py index 46981091..383eed98 100644 --- a/shared_utils/advanced_markdown_format.py +++ b/shared_utils/advanced_markdown_format.py @@ -458,6 +458,11 @@ def contain_html_tag(text): return re.search(pattern, text) is not None +def contain_image(text): + pattern = r'

' + return re.search(pattern, text) is not None + + def compat_non_markdown_input(text): """ 改善非markdown输入的显示效果,例如将空格转换为 ,将换行符转换为
等。 @@ -468,8 +473,11 @@ def compat_non_markdown_input(text): return text elif ("<" in text) and (">" in text) and contain_html_tag(text): # careful input:html输入 - escaped_text = html.escape(text) - return escaped_text + if contain_image(text): + return text + else: + escaped_text = html.escape(text) + return escaped_text else: # whatever input:非markdown输入 lines = text.split("\n")