this repo has no description

appview/pages : fix handle parsing false-positives

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

authored by estym and committed by tangled.org ec832d14 2642ed24

Changed files
+14
appview
pages
markup
extension
+14
appview/pages/markup/extension/atlink.go
··· 36 } 37 38 var atRegexp = regexp.MustCompile(`(^|\s|\()(@)([a-zA-Z0-9.-]+)(\b)`) 39 40 type atParser struct{} 41 ··· 55 if m == nil { 56 return nil 57 } 58 atSegment := text.NewSegment(segment.Start, segment.Start+m[1]) 59 block.Advance(m[1]) 60 node := &AtNode{}
··· 36 } 37 38 var atRegexp = regexp.MustCompile(`(^|\s|\()(@)([a-zA-Z0-9.-]+)(\b)`) 39 + var markdownLinkRegexp = regexp.MustCompile(`(?ms)\[.*\]\(.*\)`) 40 41 type atParser struct{} 42 ··· 56 if m == nil { 57 return nil 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 + 72 atSegment := text.NewSegment(segment.Start, segment.Start+m[1]) 73 block.Advance(m[1]) 74 node := &AtNode{}