argumentText
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.
Flattens an AST argument to readable text. Use it for names, keys, and other plain-text arguments; use renderChildren when nested formatting must survive.
Signature
ts
function argumentText(argument: SnaptexAstArgument | undefined): stringReturns
The recursively concatenated text content of argument nodes, or an empty string when the argument is absent. AST whitespace nodes become ordinary spaces.
Call relationships
- Called after:
readRequiredMacroArgumentorreadOptionalMacroArgument. - Called by:
readAstCommandArguments. - Does not: render nested LaTeX to HTML.
ts
const label = argumentText(readRequiredMacroArgument(node));Use renderChildren when nested structure and formatting must be preserved.