Monorepo for Tangled tangled.org

appview/pages : fix handle parsing false-positives

Signed-off-by: estym <evann.regnault@pm.me>

Changed files
+14
appview
pages
markup
extension
+14
appview/pages/markup/extension/atlink.go
··· 36 36 } 37 37 38 38 var atRegexp = regexp.MustCompile(`(^|\s|\()(@)([a-zA-Z0-9.-]+)(\b)`) 39 + var markdownLinkRegexp = regexp.MustCompile(`(?ms)\[.*\]\(.*\)`) 39 40 40 41 type atParser struct{} 41 42 ··· 55 56 if m == nil { 56 57 return nil 57 58 } 59 + 60 + if !util.IsSpaceRune(block.PrecendingCharacter()) { 61 + return nil 62 + } 63 + 64 + // Check for all links in the markdown to see if the handle found is inside one 65 + linksIndexes := markdownLinkRegexp.FindAllIndex(block.Source(), -1) 66 + for _, linkMatch := range linksIndexes { 67 + if linkMatch[0] < segment.Start && segment.Start < linkMatch[1] { 68 + return nil 69 + } 70 + } 71 + 58 72 atSegment := text.NewSegment(segment.Start, segment.Start+m[1]) 59 73 block.Advance(m[1]) 60 74 node := &AtNode{}