readRequiredMacroArgument
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.
Reads an argument attached to an AST macro whose opening delimiter is {. Use it when the parser is known to attach the command arguments; use readAstCommandArguments for unknown commands with detached sibling groups.
Signature
ts
function readRequiredMacroArgument(
node: SnaptexAstMacro,
index = 0
): SnaptexAstArgument | undefinedParameters
index counts only attached required arguments, not optional arguments.
Returns
The matching AST argument or undefined. It does not search sibling nodes for a detached group.
Call relationships
- Called by:
readAstCommandArgumentsand direct AST rules. - Often followed by:
argumentText.
ts
const title = argumentText(readRequiredMacroArgument(node));Use readAstCommandArguments when unknown commands may have detached sibling groups.