Skip to content

Commit 921eacd

Browse files
content: Handle message links
Fixes: #1046
1 parent ffa41be commit 921eacd

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/model/content.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,9 @@ class _ZulipContentParser {
855855

856856
if (localName == 'a'
857857
&& (className.isEmpty
858-
|| (className == 'stream-topic' || className == 'stream'))) {
858+
|| className == 'stream-topic'
859+
|| className == 'stream'
860+
|| className == 'message-link')) {
859861
final href = element.attributes['href'];
860862
if (href == null) return unimplemented();
861863
final link = LinkNode(nodes: nodes(), url: href, debugHtmlNode: debugHtmlNode);

test/model/content_test.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,17 @@ class ContentExample {
195195
GlobalTimeNode(
196196
datetime: DateTime.parse("2024-03-07T23:00:00Z")));
197197

198+
static final messageLink = ContentExample.inline(
199+
'message link',
200+
'#**api design>notation for near links@1972281**',
201+
// https://chat.zulip.org/#narrow/channel/7-test-here/topic/Rajesh/near/1976383
202+
'<p><a class="message-link" '
203+
'href="/#narrow/channel/378-api-design/topic/notation.20for.20near.20links/near/1972281">'
204+
'#api design &gt; notation for near links @ 💬</a></p>',
205+
const LinkNode(
206+
url: '/#narrow/channel/378-api-design/topic/notation.20for.20near.20links/near/1972281',
207+
nodes: [TextNode('#api design > notation for near links @ 💬')]));
208+
198209
static const spoilerDefaultHeader = ContentExample(
199210
'spoiler with default header',
200211
'```spoiler\nhello world\n```',
@@ -973,6 +984,8 @@ void main() {
973984
'#mobile-team &gt; zulip-flutter</a></p>',
974985
const LinkNode(url: '/#narrow/stream/243-mobile-team/topic/zulip-flutter',
975986
nodes: [TextNode('#mobile-team > zulip-flutter')]));
987+
988+
testParseExample(ContentExample.messageLink);
976989
});
977990

978991
testParseInline('parse nested link, del, strong, em, code',

0 commit comments

Comments
 (0)