Skip to content

context.renderCitation ​

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 a supported citation command using the current bibliography and citation state. Prefer it over rebuilding cite/citep/citet formatting inside a custom AST rule.

Signature ​

ts
context.renderCitation(
    command: string,
    keys: readonly string[],
    options: { pre?: string; post?: string }
): string

Parameters ​

command is the LaTeX command name without its backslash. keys contains parsed citation keys. pre and post represent optional citation notes.

Returns ​

Direct citation HTML appropriate for the configured command and current bibliography entries.

Call relationships ​

  • Called by: AST citation-family rules.
  • Uses: bibliography entries plus context.resolveCitation.
  • Updates: the current cited-key list.
ts
const html = context.renderCitation('citep', ['smith2024'], {
    pre: 'see',
    post: 'p. 4'
});

See also ​

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