codly / docs

Make it yours

Applies to code displayed in the documentation.

GitHub

codly.annotation-config

Describes an annotation attached to one or more one-indexed source lines in a code block.

Signature

typst code
codly.annotation-config(start, end: none, content: none, label: none, numbering: numbering.with("(1)"))

Parameters

Field Type Default / required Meaning
start int Required, positional First covered source line, one-based and positive.
end none | int none Last covered source line, inclusive; none selects start only.
content none | content none Annotation content; none displays only its automatic number.
label none | label none Label for a native annotation reference when the containing block has a block-label.
numbering none | function numbering.with("(1)") Automatic annotation number formatter; none hides the number.

Behavior

The positional start argument is required. The constructor also accepts a dictionary with a start key. Dictionary and constructor inputs are type-checked, then normalized: a missing or none end becomes start, and missing content becomes none. start and a supplied end must be positive, and end must not precede start.

Annotations are passed in the code block’s annotations array.

Example: Basic Usage

Typst source
#import "@preview/codly:2.0.0" as codly

#codly.new(
  ```py
  prepare()
  result = compute()
  print(result)
  cleanup()
  ```,
  annotations: (
    codly.annotation-config(
      2,
      end: 3,
      content: [These lines compute\ and display the result.],
    ),
  ),
)
Edit & run on your device

The highlighted source and output update after you stop typing. Copy code includes your edits.

OUTPUTPre-rendered default
Rendered output of the Typst example