MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / ExtractWikilinks

Function ExtractWikilinks

apps/server/internal/vault/parse.go:101–125  ·  view source on GitHub ↗

ExtractWikilinks returns unique [[wikilink]] targets, ignoring code.

(body string)

Source from the content-addressed store, hash-verified

99
100// ExtractWikilinks returns unique [[wikilink]] targets, ignoring code.
101func ExtractWikilinks(body string) []string {
102 if !strings.Contains(body, "[[") {
103 return []string{}
104 }
105 stripped := stripCodeContent(body)
106 seen := map[string]bool{}
107 out := []string{}
108 for _, m := range wikilinkRe.FindAllStringSubmatch(stripped, -1) {
109 if len(m) >= 3 {
110 bang := m[1]
111 target := strings.TrimSpace(m[2])
112 if target == "" {
113 continue
114 }
115 if bang == "!" && localAssetTargetKind(target) != "" {
116 continue
117 }
118 if !seen[target] {
119 seen[target] = true
120 out = append(out, target)
121 }
122 }
123 }
124 return out
125}
126
127// BodyHasLocalAsset is the same cheap heuristic as the TS version.
128func BodyHasLocalAsset(body string) bool {

Callers 2

buildNoteMetaFunction · 0.85

Calls 3

appendFunction · 0.85
stripCodeContentFunction · 0.70
localAssetTargetKindFunction · 0.70