mirror of
https://github.com/zulip/zulip.git
synced 2025-11-01 20:44:04 +00:00
stream_topic_link: Add support for empty string topic in syntax.
This commit adds support for empty string as a valid topic name in syntax for linking to topics. The server stores it after empty string is replaced with `realm_empty_topic_display_name` and wrapped with an <em> tag. The web client parses the rendered_content and updates the topic_name part in the HTML with topic_name in user's language + wraps it in a <span> tag with 'empty-topic-display' css class.
This commit is contained in:
committed by
Tim Abbott
parent
3759525807
commit
e08bf15682
@@ -177,7 +177,7 @@ STREAM_TOPIC_LINK_REGEX = rf"""
|
||||
\#\*\* # and after hash sign followed by double asterisks
|
||||
(?P<stream_name>[^\*>]+) # stream name can contain anything except >
|
||||
> # > acts as separator
|
||||
(?P<topic_name>[^\*]+) # topic name can contain anything
|
||||
(?P<topic_name>[^\*]*) # topic name can be an empty string or contain anything
|
||||
\*\* # ends by double asterisks
|
||||
"""
|
||||
|
||||
@@ -2066,8 +2066,16 @@ class StreamTopicPattern(StreamTopicMessageProcessor):
|
||||
topic_url = hash_util_encode(topic_name)
|
||||
link = f"/#narrow/channel/{stream_url}/topic/{topic_url}"
|
||||
el.set("href", link)
|
||||
text = f"#{stream_name} > {topic_name}"
|
||||
el.text = markdown.util.AtomicString(text)
|
||||
|
||||
if topic_name == "":
|
||||
topic_el = Element("em")
|
||||
topic_el.text = Message.EMPTY_TOPIC_FALLBACK_NAME
|
||||
el.text = markdown.util.AtomicString(f"#{stream_name} > ")
|
||||
el.append(topic_el)
|
||||
else:
|
||||
text = f"#{stream_name} > {topic_name}"
|
||||
el.text = markdown.util.AtomicString(text)
|
||||
|
||||
return el, m.start(), m.end()
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user