From 921eacd479381f8a57d6be42ee38088718016612 Mon Sep 17 00:00:00 2001 From: Rajesh Malviya Date: Wed, 6 Nov 2024 09:44:50 +0530 Subject: [PATCH] content: Handle message links Fixes: #1046 --- lib/model/content.dart | 4 +++- test/model/content_test.dart | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/model/content.dart b/lib/model/content.dart index 1a919d942d..0c797795ac 100644 --- a/lib/model/content.dart +++ b/lib/model/content.dart @@ -855,7 +855,9 @@ class _ZulipContentParser { if (localName == 'a' && (className.isEmpty - || (className == 'stream-topic' || className == 'stream'))) { + || className == 'stream-topic' + || className == 'stream' + || className == 'message-link')) { final href = element.attributes['href']; if (href == null) return unimplemented(); final link = LinkNode(nodes: nodes(), url: href, debugHtmlNode: debugHtmlNode); diff --git a/test/model/content_test.dart b/test/model/content_test.dart index d06d414916..3bcdaf8a5d 100644 --- a/test/model/content_test.dart +++ b/test/model/content_test.dart @@ -195,6 +195,17 @@ class ContentExample { GlobalTimeNode( datetime: DateTime.parse("2024-03-07T23:00:00Z"))); + static final messageLink = ContentExample.inline( + 'message link', + '#**api design>notation for near links@1972281**', + // https://chat.zulip.org/#narrow/channel/7-test-here/topic/Rajesh/near/1976383 + '

' + '#api design > notation for near links @ 💬

', + const LinkNode( + url: '/#narrow/channel/378-api-design/topic/notation.20for.20near.20links/near/1972281', + nodes: [TextNode('#api design > notation for near links @ 💬')])); + static const spoilerDefaultHeader = ContentExample( 'spoiler with default header', '```spoiler\nhello world\n```', @@ -973,6 +984,8 @@ void main() { '#mobile-team > zulip-flutter

', const LinkNode(url: '/#narrow/stream/243-mobile-team/topic/zulip-flutter', nodes: [TextNode('#mobile-team > zulip-flutter')])); + + testParseExample(ContentExample.messageLink); }); testParseInline('parse nested link, del, strong, em, code',