Parse keywords as links
This commit is contained in:
parent
9977fac51a
commit
085c41dabe
14
util.go
14
util.go
|
@ -41,7 +41,7 @@ func RandStringBytes(n int) string {
|
|||
|
||||
func ParseLinks(blockId string, content string) ([]ParsedLink, error) {
|
||||
hrefRE := regexp.MustCompile(`(#?\[\[\s*([^\]]+)\s*\]\])`)
|
||||
// keywordsRE := regexp.MustCompile(`(\w+)::`)
|
||||
keywordsRE := regexp.MustCompile(`(\w+)::`)
|
||||
|
||||
scanner := bufio.NewScanner(strings.NewReader(content))
|
||||
scanner.Split(bufio.ScanLines)
|
||||
|
@ -68,12 +68,12 @@ func ParseLinks(blockId string, content string) ([]ParsedLink, error) {
|
|||
result = append(result, ParsedLink{blockId, link, l, line, ""})
|
||||
}
|
||||
|
||||
// keywords := keywordsRE.FindAllStringSubmatch(line, -1)
|
||||
// for _, matches := range keywords {
|
||||
// link := matches[1]
|
||||
// l := cleanNameURL(link)
|
||||
// result = append(result, ParsedLink{blockId, link, l, line})
|
||||
// }
|
||||
keywords := keywordsRE.FindAllStringSubmatch(line, -1)
|
||||
for _, matches := range keywords {
|
||||
link := matches[1]
|
||||
l := cleanNameURL(link)
|
||||
result = append(result, ParsedLink{blockId, link, l, line, ""})
|
||||
}
|
||||
}
|
||||
|
||||
return result, nil
|
||||
|
|
Loading…
Reference in New Issue
Block a user