From 912a179485388b5473353ec97f9ce0030ad2c725 Mon Sep 17 00:00:00 2001 From: estym Date: Sun, 21 Dec 2025 03:35:59 +0100 Subject: [PATCH] appview/pages : fix handle parsing false-positives Signed-off-by: estym --- appview/pages/markup/extension/atlink.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/appview/pages/markup/extension/atlink.go b/appview/pages/markup/extension/atlink.go index 2033171c..8fba3cf5 100644 --- a/appview/pages/markup/extension/atlink.go +++ b/appview/pages/markup/extension/atlink.go @@ -36,6 +36,7 @@ func (n *AtNode) Kind() ast.NodeKind { } var atRegexp = regexp.MustCompile(`(^|\s|\()(@)([a-zA-Z0-9.-]+)(\b)`) +var markdownLinkRegexp = regexp.MustCompile(`(?ms)\[.*\]\(.*\)`) type atParser struct{} @@ -55,6 +56,19 @@ func (s *atParser) Parse(parent ast.Node, block text.Reader, pc parser.Context) if m == nil { return nil } + + if !util.IsSpaceRune(block.PrecendingCharacter()) { + return nil + } + + // Check for all links in the markdown to see if the handle found is inside one + linksIndexes := markdownLinkRegexp.FindAllIndex(block.Source(), -1) + for _, linkMatch := range linksIndexes { + if linkMatch[0] < segment.Start && segment.Start < linkMatch[1] { + return nil + } + } + atSegment := text.NewSegment(segment.Start, segment.Start+m[1]) block.Advance(m[1]) node := &AtNode{} -- 2.43.0