codly / docs

Make it yours

Applies to code displayed in the documentation.

GitHub

codly.range

Selects an inclusive range of one-indexed source lines for a code block.

Signature

typst code
codly.range(start, end: none)

start is positional and required. end is optional and may be passed positionally or by name.

Parameters

Field Type Default / required Meaning
start int Required, positional First source line of the range, one-based.
end none | int none, positional Last source line, inclusive; none selects the remainder of the block.

Behavior

Pass a range to codly.new’s range field, or pass several ranges to its ranges field. An open range such as codly.range(3) continues through the final source line.

The constructor accepts positional arguments (codly.range(2, 4)) or named arguments (codly.range(start: 2, end: 4)). Implicit casts accept a one- or two-element array or a dictionary with start and optional end keys; unknown dictionary keys are rejected. Bounds are type-checked as integers (or none for end), with no positivity or ordering constraint.

Example: Basic Usage

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

#codly.new(
  ```
  prepare()
  validate()
  transform()
  save()
  ```,
  range: codly.range(2, 3),
)
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