Skip to content

context.renderRef ​

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.

Renders one or more reference targets as preview links. Call it from an AST rule after reading the labels from \ref, \ref*, \eqref, or \eqref*.

Signature ​

ts
context.renderRef(
    labels: readonly string[],
    type: 'ref' | 'eqref'
): string

Returns ​

Direct reference-link HTML. eqref applies equation-style parentheses; numbering placeholders are resolved by the normal scanner/update pipeline.

Call relationships ​

  • Called by: AST \\ref, \\ref*, \\eqref, and \\eqref* rules.
  • Targets anchors created by: context.renderLabel.
ts
return { html: context.renderRef(['eq:loss'], 'eqref') };

See also ​

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