package link import ( "regexp" "strings" ) var linkRe = regexp.MustCompile(`\[\[(.+?)\]\]`) func ExtractLinks(body string) []string { matches := linkRe.FindAllStringSubmatch(body, -1) if len(matches) == 0 { return nil } seen := map[string]bool{} var result []string for _, m := range matches { text := strings.TrimSpace(m[1]) if text == "" || seen[text] { continue } seen[text] = true result = append(result, text) } return result }