MCPcopy Create free account
hub / github.com/Qinbf/groundmap / parseWikilinks

Function parseWikilinks

web/lib/markdown.ts:184–203  ·  view source on GitHub ↗
(content: string)

Source from the content-addressed store, hash-verified

182}
183
184export function parseWikilinks(content: string): WikiLink[] {
185 // 用 matchAll 而非 exec 循环:
186 // - matchAll 内部独立维护 iterator state,**不依赖共享 regex 的 lastIndex**
187 // - 高并发场景下两个请求同时进入此函数也不会互相覆盖匹配位置
188 const out: WikiLink[] = [];
189 for (const m of content.matchAll(WIKILINK_RE)) {
190 if (m.index === undefined) continue;
191 const { alias, relation } = splitAliasOrRelation(m[3]);
192 out.push({
193 target: m[1],
194 anchor: m[2] || null,
195 alias,
196 relation,
197 raw: m[0],
198 start: m.index,
199 end: m.index + m[0].length,
200 });
201 }
202 return out;
203}
204
205/** 标准化链接目标:补 .md 后缀 */
206export function normalizeLinkTarget(target: string): string {

Callers 3

FrontmatterPanelFunction · 0.90
getBacklinksFunction · 0.90
getOutlinksFunction · 0.90

Calls 1

splitAliasOrRelationFunction · 0.85

Tested by

no test coverage detected