Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

markdown_util: Support creating Markdown syntax with inline thumbnmail.

PieterCKfafcbee836de
diff --git a/zerver/lib/markdown/__init__.py b/zerver/lib/markdown/__init__.py
index 7565bbe1251..19fa10f6957 100644
--- a/zerver/lib/markdown/__init__.py
+++ b/zerver/lib/markdown/__init__.py
@@ -2834,9 +2834,12 @@ def render_message_markdown(
return rendering_result
-def get_markdown_link_for_url(filename: str, url: str) -> str:
+def get_markdown_link_for_url(filename: str, url: str, inline_thumbnail: bool = False) -> str:
# Our markdown has no escaping, so we cannot link any
# text containing brackets; strip them from the
# filename we're linking.
filename = re.sub(r"\[|\]", "", filename)
- return f"[{filename}]({url})"
+ markdown_link = f"[{filename}]({url})"
+ if inline_thumbnail:
+ markdown_link = "!" + markdown_link
+ return markdown_link