Parsing /parse
/parse loads the default parser (the wikiparser-node@1.48.1 browser bundle) and does not load React. Parsing is synchronous.
parseWikitext
Uses the shared parser with default configuration; suitable for one-off parsing and simple scenarios.
createWikiparser
- The default config is
MEDIAWIKI_CONFIG, a snapshot of thewikiparser-node@1.48.1site configuration. - Configuration is deep-cloned and normalized when the factory is created; later mutations of the original object do not affect the parser.
- Changing config requires creating a new parser.
- The library does not export a minimum config. For custom config, copy the default and adjust fields.
Parse options
Effective budgets merge in this order: per-call options → factory defaults → shared defaults. CRLF / CR is normalized to LF before parsing, and budgets are checked after normalization.
retainSyntax significantly increases memory and build cost; enable it only for source positions or the playground syntax tree.
Returned document
meta contains:
parser/parserVersion.pageName.astSchemaVersionand optionalsyntaxSchemaVersion.sourceNormalized,originalLength, andretainSyntax.
The same source with a different config or pageName can produce a different AST; those are parse inputs, not render options.
Custom adapter
createWikitextParser does not load the default IIFE, which makes it suitable for other parsers:
- The adapter only maps source → syntax tree; normalization, budget merging, semantic AST construction, diagnostics, and meta are handled by the factory.
context.limitsprovides the effectivemaxSyntaxNodesandmaxDepthso adapters can stop early.- The factory still validates structure, ranges, and budgets after the adapter returns.
- The adapter's
name/versionare written to document meta.
Errors
Node and depth limits are internal guardrails. The effective values appear in error.message when triggered and are not exported as constants.