@tola/diagnostic

Emit custom errors, warnings, info messages, and hints during Typst evaluation.

Import

typst
#import "@tola/diagnostic:0.0.0": *

Exports

report

typc
let report(
  message: str,
  at: content | none | auto = auto,
  code: str | none = none,
  hints: array = (),
  related: array = (),
  severity: str = "warning",
) = none;

Record a site diagnostic without immediately aborting Typst evaluation.

Any "error" diagnostic fails tola check and tola build after evaluation finishes, while "warning", "info", and "hint" allow the build to succeed. Use Typst’s panic(...) only when evaluation cannot continue.

Positional parameters

  • message str required: Human-readable explanation of the issue.

Named parameters

  • severity str default: "warning": Diagnostic level: "error", "warning" (default), "info", or "hint".
  • code str | none default: none: Optional rule identifier owned by your site or module (for example "missing-summary").
  • at content | none | auto default: auto: Location anchor: auto (default) points to the report(...) call, Typst content points to that element’s source span, and none omits location.
  • hints array default: (): Optional array of short fix suggestions shown below the message.
  • related array default: (): Optional array of (message: str, at: content | none) records pointing to related spans.

Warn when an article omits a description

typst
#import "@tola/diagnostic:0.0.0": report

#let check-page(title, description) = {
  if description == none {
    report(
      "Page \"" + title + "\" is missing a description.",
      severity: "warning",
      code: "site.missing-description",
      hints: ("Add `description` in `tola-meta`.",),
    )
  }
}

Search this site

Use the arrow keys to move through results.

Type to search.