unified
/unified loads neither the default parser nor React. It exposes the pipeline as three unified plugins for hosts that already own a processor and need custom transforms in between.
Warning
Raw mode does not add the security stage or arrange plugin order for you. When you need the fixed order, prefer prepareWikitext.
A typical processor
wikitextParse
- Parses the source into
WikitextDocumentand stores it on the VFile. - Returns an independent working tree; parsing the same VFile again resets library fields but does not clear the caller's other
data. - A parser is required;
/unifiednever loadswikiparser-nodeimplicitly.
wikitextRehype
- Reads the parse result from the VFile and uses the tree the processor actually passes in, not a stale cached tree.
- Validates the working tree and its budget, reassigns ids, and converts to HAST.
- Stores the preparation context before the security stage.
- Options contain preparation settings only (resolvers,
policy,labels,headingIdStrategy, andhandlers). - It does not run
wikitextPlugins/rehypePlugins; passing either field (even an empty array) throwsPREPARE_FAILED. Register plugins on the processor with.use(...).
wikitextFinalize
- Must run after every rehype plugin.
- Sanitizes and finalizes, then writes
wikitextRenderDocumentto the VFile. - An explicit
headingIdStrategyoverrides the preparation setting for both the final headings and snapshot meta. - Nothing can be inserted afterwards; HAST that skips this plugin is not a render document.
Errors and prerequisites
- Without
wikitextParse,wikitextRehypethrowsWikitextPrepareError("INVALID_DOCUMENT")withstage: "prepare". - Without
wikitextRehype,wikitextFinalizethrowsWikitextPrepareError("PREPARE_FAILED"). - These errors do not repair plugin order; inspect the processor chain.
When not to use raw mode
Related
- Preparation
/hast: fixed security order, resolvers, and policy. - AST
/ast: semantic nodes and queries. - Errors and diagnostics:
WikitextPrepareErrorfields.