topic_link_util: Make stream topic link syntax consistent.

We pad the `>` with spaces in the generated fallback link to make
it consistent with other places where the syntax is used.

Fixes part of #31920
This commit is contained in:
Kislay Udbhav Verma 2024-10-27 19:11:28 +05:30 committed by Tim Abbott
parent 000cc7bcde
commit fad7a3f4b4
3 changed files with 14 additions and 14 deletions

View File

@ -43,7 +43,7 @@ export function get_fallback_markdown_link(stream_name: string, topic_name?: str
assert(stream_id !== undefined);
const escape = html_escape_markdown_syntax_characters;
if (topic_name !== undefined) {
return `[#${escape(stream_name)}>${escape(topic_name)}](${internal_url.by_stream_topic_url(stream_id, topic_name, () => stream_name)})`;
return `[#${escape(stream_name)} > ${escape(topic_name)}](${internal_url.by_stream_topic_url(stream_id, topic_name, () => stream_name)})`;
}
return `[#${escape(stream_name)}](${internal_url.by_stream_url(stream_id, () => stream_name)})`;
}

View File

@ -49,23 +49,23 @@ run_test("try_stream_topic_syntax_text", () => {
// #**stream>topic** urls is pasted, a normal markdown link syntax is produced.
[
"http://zulip.zulipdev.com/#narrow/stream/4-Rome/topic/100.25.20profits.60",
"[#Rome>100% profits`](#narrow/channel/4-Rome/topic/100.25.20profits.60)",
"[#Rome > 100% profits`](#narrow/channel/4-Rome/topic/100.25.20profits.60)",
],
[
"http://zulip.zulipdev.com/#narrow/stream/4-Rome/topic/100.25.20*profits",
"[#Rome>100% *profits](#narrow/channel/4-Rome/topic/100.25.20*profits)",
"[#Rome > 100% *profits](#narrow/channel/4-Rome/topic/100.25.20*profits)",
],
[
"http://zulip.zulipdev.com/#narrow/stream/4-Rome/topic/.24.24 100.25.20profits",
"[#Rome>$$ 100% profits](#narrow/channel/4-Rome/topic/.24.24.20100.25.20profits)",
"[#Rome > $$ 100% profits](#narrow/channel/4-Rome/topic/.24.24.20100.25.20profits)",
],
[
"http://zulip.zulipdev.com/#narrow/stream/4-Rome/topic/>100.25.20profits",
"[#Rome>>100% profits](#narrow/channel/4-Rome/topic/.3E100.25.20profits)",
"[#Rome > >100% profits](#narrow/channel/4-Rome/topic/.3E100.25.20profits)",
],
[
"http://zulip.zulipdev.com/#narrow/stream/5-Romeo.60s-lair/topic/normal",
"[#Romeo`s lair>normal](#narrow/channel/5-Romeo.60s-lair/topic/normal)",
"[#Romeo`s lair > normal](#narrow/channel/5-Romeo.60s-lair/topic/normal)",
],
];

View File

@ -47,31 +47,31 @@ run_test("stream_topic_link_syntax_test", () => {
);
assert.equal(
topic_link_util.get_stream_topic_link_syntax("#**Sweden>t", "test `test` test"),
"[#Sweden>test `test` test](#narrow/channel/1-Sweden/topic/test.20.60test.60.20test)",
"[#Sweden > test `test` test](#narrow/channel/1-Sweden/topic/test.20.60test.60.20test)",
);
assert.equal(
topic_link_util.get_stream_topic_link_syntax("#**Denmark>t", "test `test` test`s"),
"[#Denmark>test `test` test`s](#narrow/channel/2-Denmark/topic/test.20.60test.60.20test.60s)",
"[#Denmark > test `test` test`s](#narrow/channel/2-Denmark/topic/test.20.60test.60.20test.60s)",
);
assert.equal(
topic_link_util.get_stream_topic_link_syntax("#**Sweden>typeah", "error due to *"),
"[#Sweden>error due to *](#narrow/channel/1-Sweden/topic/error.20due.20to.20*)",
"[#Sweden > error due to *](#narrow/channel/1-Sweden/topic/error.20due.20to.20*)",
);
assert.equal(
topic_link_util.get_stream_topic_link_syntax("#**Sweden>t", "*asterisk"),
"[#Sweden>*asterisk](#narrow/channel/1-Sweden/topic/*asterisk)",
"[#Sweden > *asterisk](#narrow/channel/1-Sweden/topic/*asterisk)",
);
assert.equal(
topic_link_util.get_stream_topic_link_syntax("#**Sweden>gibberish", "greaterthan>"),
"[#Sweden>greaterthan>](#narrow/channel/1-Sweden/topic/greaterthan.3E)",
"[#Sweden > greaterthan>](#narrow/channel/1-Sweden/topic/greaterthan.3E)",
);
assert.equal(
topic_link_util.get_stream_topic_link_syntax("#**$$MONEY$$>t", "dollar"),
"[#$$MONEY$$>dollar](#narrow/channel/6-.24.24MONEY.24.24/topic/dollar)",
"[#$$MONEY$$ > dollar](#narrow/channel/6-.24.24MONEY.24.24/topic/dollar)",
);
assert.equal(
topic_link_util.get_stream_topic_link_syntax("#**Sweden>t", "swe$$dish"),
"[#Sweden>swe$$dish](#narrow/channel/1-Sweden/topic/swe.24.24dish)",
"[#Sweden > swe$$dish](#narrow/channel/1-Sweden/topic/swe.24.24dish)",
);
assert.equal(
topic_link_util.get_fallback_markdown_link("Sweden"),
@ -85,7 +85,7 @@ run_test("stream_topic_link_syntax_test", () => {
assert.equal(
topic_link_util.get_stream_topic_link_syntax("#**Sweden>&ab", "&ab"),
"[#Sweden>&ab](#narrow/channel/1-Sweden/topic/.26ab)",
"[#Sweden > &ab](#narrow/channel/1-Sweden/topic/.26ab)",
);
// Only for full coverage of the module.