markdown: Support message link syntax in local echo.

This is a followup to #31965 where we added
support for a new syntax for message links.
The frontend markdown processor didn't local
echo the syntax properly, resulting in a
rendering glitch in the messages.
This commit is contained in:
Kislay Verma
2024-12-03 20:33:16 +05:30
committed by Tim Abbott
parent c56cc14539
commit dfc1ea785f
3 changed files with 71 additions and 0 deletions

View File

@@ -545,6 +545,7 @@ inline.zulip = merge({}, inline.breaks, {
unicodeemoji: possible_emoji_regex,
usermention: /^@(_?)(?:\*\*([^\*]+)\*\*)/, // Match potentially multi-word string between @** **
groupmention: /^@(_?)(?:\*([^\*]+)\*)/, // Match multi-word string between @* *
stream_topic_message: /^#\*\*([^\*>]+)>([^\*]+)@(\d+)\*\*/,
stream_topic: /^#\*\*([^\*>]+)>([^\*]+)\*\*/,
stream: /^#\*\*([^\*]+)\*\*/,
tex: /^(\$\$([^\n_$](\\\$|[^\n$])*)\$\$(?!\$))\B/,
@@ -754,6 +755,13 @@ InlineLexer.prototype.output = function(src) {
continue;
}
// stream_topic_message (Zulip)
if (cap = this.rules.stream_topic_message.exec(src)) {
src = src.substring(cap[0].length);
out += this.stream_topic_message(unescape(cap[1]), unescape(cap[2]), unescape(cap[3]), cap[0]);
continue;
}
// stream_topic (Zulip)
if (cap = this.rules.stream_topic.exec(src)) {
src = src.substring(cap[0].length);
@@ -950,6 +958,18 @@ InlineLexer.prototype.stream_topic = function (streamName, topic, orig) {
return orig;
};
InlineLexer.prototype.stream_topic_message = function (streamName, topic, message_id, orig) {
orig = escape(orig);
if (typeof this.options.streamTopicMessageHandler !== 'function')
return orig;
var handled = this.options.streamTopicMessageHandler(streamName, topic, message_id);
if (handled !== undefined) {
return handled;
}
return orig;
};
/**
* Smartypants Transformations
*/