MdzContainerNodeType import type {MdzContainerNodeType} from '@fuzdev/fuz_ui/mdz_opcodes.js'; Node types that can be opened as containers.
Opcode types for the mdz streaming parser.
Opcodes are serializable rendering instructions emitted by MdzStreamParser. They tell a renderer what to do next — open a container, append text, close it, or revert an optimistic assumption. Target-agnostic: works for HTML, Svelte, PDF, etc.
The parser makes optimistic assumptions about ambiguous syntax (e.g., ** is probably bold)
and emits revert opcodes to correct when wrong. This enables true streaming rendering
without ever re-parsing.
14 declarations
MdzContainerNodeType import type {MdzContainerNodeType} from '@fuzdev/fuz_ui/mdz_opcodes.js'; Node types that can be opened as containers.
number import type {MdzNodeId} from '@fuzdev/fuz_ui/mdz_opcodes.js'; Unique monotonic identifier for each node created by the parser. IDs are never reused within a parser instance.
MdzNodeType import type {MdzNodeType} from '@fuzdev/fuz_ui/mdz_opcodes.js'; All node types that can appear in the mdz tree.
MdzOpcode import type {MdzOpcode} from '@fuzdev/fuz_ui/mdz_opcodes.js'; Discriminated union of all mdz opcodes.
MdzOpcodeAppendText import type {MdzOpcodeAppendText} from '@fuzdev/fuz_ui/mdz_opcodes.js'; Append content to an existing text node. Streaming optimization — avoids creating a new node per chunk during plain text runs.
typetype 'append_text'
idtype MdzNodeId
contenttype string
MdzOpcodeClose import type {MdzOpcodeClose} from '@fuzdev/fuz_ui/mdz_opcodes.js'; Close a previously opened container node. Carries deferred metadata that wasn't known at open time.
typetype 'close'
idtype MdzNodeId
endByte offset in the full input immediately after the closing delimiter.
type number
reference?Link URL/path, resolved when ](url) completes.
type string
link_type?Link type, resolved alongside reference.
type 'external' | 'internal'
heading_id?Heading slug, computed from full heading content.
type string
discard?If true, consumer drops this node and its descendants from the tree. Used for whitespace-only paragraphs that match nothing in mdz_parse's output — the streaming parser emits open/text speculatively, then retroactively drops the empty wrapper at close.
type boolean
MdzOpcodeOpen import type {MdzOpcodeOpen} from '@fuzdev/fuz_ui/mdz_opcodes.js'; Open a container node. The renderer starts a new element/wrapper.
Children are subsequent opcodes until the matching close.
typetype 'open'
idtype MdzNodeId
node_typetype MdzContainerNodeType
startByte offset in the full input where the opening delimiter begins.
type number
level?Heading level (1-6). Present when node_type is 'Heading'.
type 1 | 2 | 3 | 4 | 5 | 6
name?Tag name. Present when node_type is 'Element' or 'Component'.
type string
lang?Language hint. Present when node_type is 'Codeblock'.
type string | null
MdzOpcodeRevert import type {MdzOpcodeRevert} from '@fuzdev/fuz_ui/mdz_opcodes.js'; Undo an optimistic open. Removes the container wrapper,
inserts replacement_text as literal text at the container's position,
and re-parents the container's children to the grandparent.
When wrap_node_type and wrap_id are set, the replacement text and
re-parented children are wrapped in a new container of the given type
instead of being placed directly at the grandparent level. The wrapper
is pushed onto the consumer's stack (open for future content). This is
used for block-level reverts (e.g., codeblock → paragraph) where the
grandparent is root and content needs a container.
typetype 'revert'
idtype MdzNodeId
replacement_textThe delimiter text to emit as literal content (e.g., "**", "[", "<Tag>").
type string
startByte offset of the original opening delimiter in the full input.
type number
wrap_node_type?Wrap replacement text and re-parented children in a new container of this type.
type MdzContainerNodeType
wrap_id?ID for the wrapper node. Required when wrap_node_type is set.
type MdzNodeId
MdzOpcodeText import type {MdzOpcodeText} from '@fuzdev/fuz_ui/mdz_opcodes.js'; Create a leaf text or code node. The parent is implicit — the innermost open container on the renderer's stack.
typetype 'text'
idtype MdzNodeId
contenttype string
text_typetype MdzTextNodeType
startByte offset where this node begins (for Code, the opening backtick).
type number
endByte offset immediately after this node ends (for Code, after the closing backtick).
type number
MdzOpcodeTrimText import type {MdzOpcodeTrimText} from '@fuzdev/fuz_ui/mdz_opcodes.js'; Trim count characters from the end of an existing text node.
If trimming empties the node, the consumer removes it from its parent.
Used by paragraph/codeblock close to drop the trailing newline that
separates inline content from the block boundary. Emitted instead of
retroactively mutating the prior text/append_text opcode, so the
opcode stream is append-only.
typetype 'trim_text'
idtype MdzNodeId
counttype number
MdzOpcodeVoid import type {MdzOpcodeVoid} from '@fuzdev/fuz_ui/mdz_opcodes.js'; Create a self-contained leaf node (e.g., horizontal rule). Inserted as a child of the innermost open container, or at root level.
typetype 'void'
idtype MdzNodeId
node_typetype MdzVoidNodeType
startByte offset in the full input where this element begins.
type number
endByte offset immediately after this element ends.
type number
MdzOpcodeWrap import type {MdzOpcodeWrap} from '@fuzdev/fuz_ui/mdz_opcodes.js'; Retroactively wrap an existing text node in a container. Used for text-first auto-links: URL/path text streams as plain text, then gets wrapped in a Link when the URL boundary is found.
When trim_end is set, trailing characters (punctuation) are trimmed
from the target text node and placed in a new sibling Text node after
the Link wrapper, identified by trim_id.
typetype 'wrap'
idID for the new Link container node.
type MdzNodeId
node_typeContainer type to wrap in (always 'Link' for now).
type 'Link'
target_idID of the existing text node to wrap.
type MdzNodeId
referenceResolved URL or path reference.
type string
link_typeWhether the link is external (URL) or internal (path).
type 'external' | 'internal'
startByte offset where the URL/path begins.
type number
endByte offset immediately after the URL/path (before any trimmed punctuation).
type number
trim_end?Number of trailing chars to trim from target and place after the link.
type number
trim_id?ID for the trimmed-text sibling node. Required when trim_end > 0.
type MdzNodeId
MdzTextNodeType import type {MdzTextNodeType} from '@fuzdev/fuz_ui/mdz_opcodes.js'; Discriminant for leaf text nodes.
"Hr" import type {MdzVoidNodeType} from '@fuzdev/fuz_ui/mdz_opcodes.js'; Node types for self-contained leaf elements.