Pull unique asset-embed targets out of markdown — both `![[asset]]` (which * extractWikilinks deliberately skips) and `` image/file embeds. The * raw targets are resolved to assets per-note by the renderer (relative path + * basename fallback), to show which notes use each asset.
(body: string)
| 1562 | * raw targets are resolved to assets per-note by the renderer (relative path + |
| 1563 | * basename fallback), to show which notes use each asset. */ |
| 1564 | function extractAssetEmbeds(body: string): string[] { |
| 1565 | const stripped = stripCodeContent(body) |
| 1566 | const seen = new Set<string>() |
| 1567 | if (stripped.includes('![[')) { |
| 1568 | const re = /!\[\[([^\]|]+?)(?:\|[^\]]+)?\]\]/g |
| 1569 | let m: RegExpExecArray | null |
| 1570 | while ((m = re.exec(stripped)) !== null) { |
| 1571 | const t = (m[1] ?? '').trim() |
| 1572 | if (t && localAssetTargetKind(t)) seen.add(t) |
| 1573 | } |
| 1574 | } |
| 1575 | if (stripped.includes('](')) { |
| 1576 | const re = /!\[[^\]]*\]\(\s*<?([^)>\s]+)>?[^)]*\)/g |
| 1577 | let m: RegExpExecArray | null |
| 1578 | while ((m = re.exec(stripped)) !== null) { |
| 1579 | const raw = (m[1] ?? '').trim() |
| 1580 | if (!raw || raw.startsWith('#') || /^[a-zA-Z][\w+.-]*:/.test(raw)) continue // skip URLs/anchors |
| 1581 | try { |
| 1582 | seen.add(decodeURIComponent(raw)) |
| 1583 | } catch { |
| 1584 | seen.add(raw) |
| 1585 | } |
| 1586 | } |
| 1587 | } |
| 1588 | return [...seen] |
| 1589 | } |
| 1590 | |
| 1591 | /** Build a short plaintext preview from markdown. */ |
| 1592 | function buildExcerpt(body: string): string { |
no test coverage detected