Pull unique `[[wikilink]]` targets out of markdown text. Supports * `[[target|label]]` by discarding the label. Ignores fenced/inline code.
(body: string)
| 1542 | /** Pull unique `[[wikilink]]` targets out of markdown text. Supports |
| 1543 | * `[[target|label]]` by discarding the label. Ignores fenced/inline code. */ |
| 1544 | function extractWikilinks(body: string): string[] { |
| 1545 | if (!body.includes('[[')) return [] |
| 1546 | const stripped = stripCodeContent(body) |
| 1547 | const re = /(!?)\[\[([^\]|]+?)(?:\|[^\]]+)?\]\]/g |
| 1548 | const seen = new Set<string>() |
| 1549 | let m: RegExpExecArray | null |
| 1550 | while ((m = re.exec(stripped)) !== null) { |
| 1551 | const bang = m[1] ?? '' |
| 1552 | const target = (m[2] ?? '').trim() |
| 1553 | if (!target) continue |
| 1554 | if (bang === '!' && localAssetTargetKind(target)) continue |
| 1555 | seen.add(target) |
| 1556 | } |
| 1557 | return [...seen] |
| 1558 | } |
| 1559 | |
| 1560 | /** Pull unique asset-embed targets out of markdown — both `![[asset]]` (which |
| 1561 | * extractWikilinks deliberately skips) and `` image/file embeds. The |
no test coverage detected