Skip to content

input.renderSource ​

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(...), and collect(...) are callbacks that your rule implements and SnapTeX calls.
  • renderer.name(...), context.name(...), input.name(...), and deps.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 constructs PreviewUpdateService.

Register extension declarations through SNAP_TEX_RULES in src/rules.ts. See Source API Scope for imports, value ownership, output safety, rebuilds, and testing.

Parses generated LaTeX source and renders the resulting AST with the current rules. Use it for macro expansion or reconstructed source, not for nodes already present in input.node.

Signature ​

ts
input.renderSource(source: string): string

Returns ​

Rendered HTML. If parsing fails, SnapTeX falls back to its inline LaTeX renderer. Generated-source recursion is capped at eight levels.

Call relationships ​

  • Provided by: the AST walker.
  • Calls: the loaded unified-latex parser, then the AST rule walker.
  • Creates: source readers scoped to the generated string.
text
generated LaTeX string -> new AST parse -> current AST rules -> HTML
ts
const expanded = input.renderSource('\\textbf{Generated text}');

This function does additional parsing. Prefer renderChildren for nodes already present in the AST.

See also ​

A fast structural preview, not a replacement for a full TeX compiler.