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

Function hasNoteEmbeds

packages/app-core/src/lib/transclusion.ts:122–130  ·  view source on GitHub ↗
(markdown: string, resolve: ExpandEmbedsCtx['resolve'], fromPath: string)

Source from the content-addressed store, hash-verified

120/** Returns true when a note's markdown contains at least one note-embed. Cheap
121 * pre-check so callers can skip the async work entirely for the common case. */
122export function hasNoteEmbeds(markdown: string, resolve: ExpandEmbedsCtx['resolve'], fromPath: string): boolean {
123 if (!markdown.includes('![[')) return false
124 const ranges = codeRanges(markdown)
125 return [...markdown.matchAll(EMBED_RE)].some((m) => {
126 if (inCode(m.index!, ranges)) return false
127 const target = (m[1].split('|', 1)[0] ?? '').trim()
128 return !!target && !!resolve(target, fromPath)
129 })
130}
131
132/** Expand every `![[Note]]` note-embed in `markdown` into inline content,
133 * recursively, with cycle + depth guards. Non-note targets are left untouched. */

Callers 2

Preview.tsxFile · 0.90

Calls 3

codeRangesFunction · 0.85
resolveFunction · 0.85
inCodeFunction · 0.70

Tested by

no test coverage detected