Disable keyword links in backrefs
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Peter Stuifzand 2021-08-17 21:35:39 +02:00
parent 9d4c6ed770
commit 61bef3b785

14
util.go
View File

@ -72,7 +72,7 @@ func RandStringBytes(n int) string {
func ParseLinks(blockId string, content string) ([]ParsedLink, error) { func ParseLinks(blockId string, content string) ([]ParsedLink, error) {
hrefRE := regexp.MustCompile(`(#?\[\[\s*([^\]]+)\s*\]\])`) hrefRE := regexp.MustCompile(`(#?\[\[\s*([^\]]+)\s*\]\])`)
keywordsRE := regexp.MustCompile(`(\w+)::`) // keywordsRE := regexp.MustCompile(`(\w+)::`)
scanner := bufio.NewScanner(strings.NewReader(content)) scanner := bufio.NewScanner(strings.NewReader(content))
scanner.Split(bufio.ScanLines) scanner.Split(bufio.ScanLines)
@ -82,12 +82,12 @@ func ParseLinks(blockId string, content string) ([]ParsedLink, error) {
for scanner.Scan() { for scanner.Scan() {
line := scanner.Text() line := scanner.Text()
keywords := keywordsRE.FindAllStringSubmatch(line, -1) // keywords := keywordsRE.FindAllStringSubmatch(line, -1)
for _, matches := range keywords { // for _, matches := range keywords {
link := matches[1] // link := matches[1]
l := cleanNameURL(link) // l := cleanNameURL(link)
result = append(result, ParsedLink{blockId, link, l, line, ""}) // result = append(result, ParsedLink{blockId, link, l, line, ""})
} // }
links := hrefRE.FindAllStringSubmatch(line, -1) links := hrefRE.FindAllStringSubmatch(line, -1)