markdown: Convert topic links generated by "#-mentions" to permalinks.

This commit converts the links generated by the markdown
of the "#-mention" of topics to permalinks -- the links containing
the "with" narrow operator, the operand being the last message
of the channel and topic of the mention.

Fixes part of #21505
This commit is contained in:
roanster007
2024-05-27 15:11:19 +05:30
committed by Tim Abbott
parent 7c90d0a588
commit 410ae119d4
8 changed files with 300 additions and 16 deletions

View File

@@ -20,6 +20,12 @@ format used by the Zulip server that they are interacting with.
## Changes in Zulip 10.0
**Feature level 347**
* [Markdown message formatting](/api/message-formatting#links-to-channels-topics-and-messages):
Links to topic without a specified message now use the `with`
operator to follow moves of topics.
**Feature level 346**
* [Markdown message formatting](/api/message-formatting#links-to-channels-topics-and-messages):

View File

@@ -38,7 +38,7 @@ Sample HTML formats are as follows:
<!-- Syntax: #**announce>Zulip updates** -->
<a class="stream-topic" data-stream-id="9"
href="/#narrow/channel/9-announce/topic/Zulip.20updates">
href="/#narrow/channel/9-announce/topic/Zulip.20updates/with/214">
#announce &gt; Zulip updates
</a>
@@ -47,9 +47,27 @@ Sample HTML formats are as follows:
href="/#narrow/channel/9-announce/topic/Zulip.20updates/near/214">
#announce &gt; Zulip updates @ 💬
</a>
<!-- Syntax: #**announce>Zulip updates**
Generated only if topic is empty or the link was rendered before
Zulip 10.0 (feature level 347) -->
<a class="stream-topic" data-stream-id="9"
href="/#narrow/channel/9-announce/topic/Zulip.20updates">
#announce &gt; Zulip updates
</a>
```
The older stream/topic elements include a `data-stream-id`, which
The `near` and `with` operators are documented in more detail in the
[search and URL documentation](/api/construct-narrow). When rendering
topic links with the `with` operator, the code doing the rendering may
pick the ID arbitrarily among messages accessible to the client and/or
acting user at the time of rendering. Currently, the server chooses
the message ID to use for `with` operators as the oldest message ID in
the topic accessible to the user who wrote the message. In channels
with protected history, this means the same Markdown syntax may be
rendered differently for users who joined at different times.
The older stream/topic link elements include a `data-stream-id`, which
historically was used in order to display the current channel name if
the channel had been renamed. That field is **deprecated**, because
displaying an updated value for the most common forms of this syntax
@@ -64,7 +82,7 @@ are as follows:
```html
<!-- Syntax: #**announce>** -->
<a class="stream-topic" data-stream-id="9"
href="/#narrow/channel/9-announce/topic/">
href="/#narrow/channel/9-announce/topic/with/214">
#announce &gt; <em>general chat</em>
</a>
@@ -73,9 +91,21 @@ are as follows:
href="/#narrow/channel/9-announce/topic//near/214">
#announce &gt; <em>general chat</em> @ 💬
</a>
<!-- Syntax: #**announce>**
Generated only if topic is empty or the link was rendered before
Zulip 10.0 (feature level 347) -->
<a class="stream-topic" data-stream-id="9"
href="/#narrow/channel/9-announce/topic/">
#announce &gt; <em>general chat</em>
</a>
```
**Changes**: Before Zulip 10.0 (feature level 346), empty string
**Changes**: Before Zulip 10.0 (feature level 347), the `with` field
was never used in topic link URLs generated by the server; the markup
currently used only for empty topics was used for all topic links.
Before Zulip 10.0 (feature level 346), empty string
was not a valid topic name in syntaxes for linking to topics and
messages.