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.

topic_link: Document get_fallback_markdown_link.

Tim Abbottb437bcd5c476
diff --git a/web/src/topic_link_util.ts b/web/src/topic_link_util.ts
index cac23899de6..831686a452b 100644
--- a/web/src/topic_link_util.ts
+++ b/web/src/topic_link_util.ts
@@ -98,6 +98,11 @@ export function get_fallback_markdown_link(
topic_name?: string,
message_id?: string,
): string {
+ // Helper that should only be called by other methods in this file.
+
+ // Generates the vanilla markdown link syntax for a stream/topic/message link, as
+ // a fallback for cases where the nicer Zulip link syntax would not
+ // render properly due to special characters in the channel or topic name.
const {text, url} = get_topic_link_content(stream_name, topic_name, message_id);
return as_markdown_link_syntax(text, url);
}
diff --git a/zerver/lib/topic_link_util.py b/zerver/lib/topic_link_util.py
index 7df86341bd7..7833585e629 100644
--- a/zerver/lib/topic_link_util.py
+++ b/zerver/lib/topic_link_util.py
@@ -48,7 +48,11 @@ def get_fallback_markdown_link(
stream_id: int, stream_name: str, topic_name: str | None = None, message_id: int | None = None
) -> str:
"""
- Generates the markdown link syntax for a stream/topic/message link.
+ Helper that should only be called by other methods in this file.
+
+ Generates the vanilla markdown link syntax for a stream/topic/message link, as
+ a fallback for cases where the nicer Zulip link syntax would not
+ render properly due to special characters in the channel or topic name.
"""
escape = escape_invalid_stream_topic_characters
link = f"#narrow/channel/{stream_id}-{encode_hash_component(stream_name.replace(' ', '-'))}"