mdz_to_svelte.ts

Converts parsed MdzNode arrays to Svelte markup strings.

Used by the svelte_preprocess_mdz preprocessor to expand static <Mdz content="..."> usages into pre-rendered Svelte markup at build time. The output for each node type matches what MdzNodeView.svelte renders at runtime, so precompiled and runtime rendering are identical.

Declarations
#

2 declarations

view source

mdz_to_svelte
#

mdz_to_svelte.ts view source

(nodes: MdzNode[], components: Record<string, string>, elements: ReadonlySet<string>): MdzToSvelteResult

Converts an array of MdzNode to a Svelte markup string.

Each node type produces output matching what MdzNodeView.svelte renders at runtime. Collects required imports and flags unconfigured component/element references.

nodes

Parsed mdz nodes to render.

type MdzNode[]

components

Component name to import path mapping (e.g., {Alert: '$lib/Alert.svelte'}). If content references a component not in this map, has_unconfigured_tags is set.

type Record<string, string>

elements

Allowed HTML element names (e.g., new Set(['aside', 'details'])). If content references an element not in this set, has_unconfigured_tags is set.

type ReadonlySet<string>

returns

MdzToSvelteResult

MdzToSvelteResult
#

mdz_to_svelte.ts view source

MdzToSvelteResult

Result of converting MdzNode arrays to Svelte markup.

markup

Generated Svelte markup string.

type string

imports

Required imports: Map<local_name, {path, kind}>.

type Map<string, {path: string; kind: 'default' | 'named'}>

has_unconfigured_tags

Whether content references unconfigured Component or Element tags.

type boolean

Imported by
#