Skip to content

Commit

Permalink
fix image display bug
Browse files Browse the repository at this point in the history
  • Loading branch information
binary-husky committed Jan 12, 2025
1 parent 7eeab9e commit 286f730
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions shared_utils/advanced_markdown_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,11 @@ def contain_html_tag(text):
return re.search(pattern, text) is not None


def contain_image(text):
pattern = r'<br/><br/><div align="center"><img src="file=(.*?)" base64="(.*?)"></div>'
return re.search(pattern, text) is not None


def compat_non_markdown_input(text):
"""
改善非markdown输入的显示效果,例如将空格转换为&nbsp;,将换行符转换为</br>等。
Expand All @@ -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")
Expand Down

0 comments on commit 286f730

Please sign in to comment.