defineRuleRegistry
How to read this API
These are TypeScript APIs compiled into SnapTeX; a .tex project cannot load them at runtime.
function name(...)is a helper that your rule imports and calls.apply(...),render(...),extract(...), andcollect(...)are callbacks that your rule implements and SnapTeX calls.renderer.name(...),context.name(...),input.name(...), anddeps.name(...)are methods SnapTeX supplies to callbacks; do not import or construct them.service.name(...)is an instance method called after your host or test constructsPreviewUpdateService.
Register extension declarations through SNAP_TEX_RULES in src/rules.ts. See Source API Scope for imports, value ownership, output safety, rebuilds, and testing.
Creates the registry consumed by document parsing and rendering. Call it when assembling the exported SNAP_TEX_RULES; it is not called from an individual render callback.
Signature
ts
function defineRuleRegistry(registry: RuleRegistry): RuleRegistryParameters
| Parameter | Description |
|---|---|
registry | Complete metadata, rendering, dependency, and splitter configuration |
Returns
A new registry object. Every array and splitterConfig is shallow-copied. renderRules is sorted by ascending priority; other arrays preserve caller order.
Call relationships
- Called while: constructing
SNAP_TEX_RULESinsrc/rules.ts. - Consumed by:
LatexDocument,SmartRenderer, andPreviewUpdateService. - Does not call: rule callbacks or render source.
text
rule constants -> defineRuleRegistry -> SNAP_TEX_RULES
-> LatexDocument + SmartRendererExample
ts
export const SNAP_TEX_RULES = defineRuleRegistry({
metadataExtractors: [BUILTIN_METADATA_EXTRACTOR],
renderRules: DEFAULT_RENDER_RULES,
astRenderRules: DEFAULT_AST_RENDER_RULES,
astMathRules: DEFAULT_AST_MATH_RULES,
blockDependencyRules: DEFAULT_BLOCK_DEPENDENCY_RULES,
splitterConfig: DEFAULT_SPLITTER_CONFIG,
splitterRules: DEFAULT_SPLITTER_RULES
});The returned registry is a lifecycle snapshot. Rebuild and reload SnapTeX after changing rule definitions.