Merge branch 'binary-husky:master' into master

This commit is contained in:
xunge 2025-01-15 10:02:29 +08:00 committed by GitHub
commit bd7cff9c9b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 2 deletions

View File

@ -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>
@ -468,8 +473,11 @@ def compat_non_markdown_input(text):
return text
elif ("<" in text) and (">" in text) and contain_html_tag(text):
# careful inputhtml输入
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")