codly.highlight-config
Describes one character-level highlight on a source line in a Codly code block. See codly.new for the block’s highlights field.
Signature
codly.highlight-config(line, start: none, end: none, fill: none, tag: none, inset: none, baseline: none, clip: none, outset: none, radius: none, label: none, stroke: none, depth: none)
line is the required positional field; every other field is named. A dictionary with a line key can also be cast to this type.
Fields
| Field | Type | Default / required | Meaning |
|---|---|---|---|
line |
int |
Required, positional | Positive displayed line number, including offsets and inserted skips. |
start |
none | int |
none |
First character to include, one-based; none or 0 selects the line start. |
end |
none | int |
none |
Last character to include, one-based and inclusive; none selects the line end. |
fill |
none | paint | function |
none |
Explicit paint or a callback receiving the next default palette paint. Explicit paints do not consume a palette color; callbacks do. none uses the palette. |
tag |
none | str | content |
none |
Optional content displayed beside the highlighted span. |
inset |
none | length | dictionary |
none |
Override for codly.highlight.inset. |
baseline |
none | length | auto |
none |
Override for the highlight box baseline; auto preserves the content's baseline. |
clip |
none | bool |
none |
Override for codly.highlight.clip. |
outset |
none | length | dictionary |
none |
Override for codly.highlight.outset. |
radius |
none | length |
none |
Override for codly.highlight.radius. |
label |
none | label |
none |
Label for a native highlight reference when the containing block has a block-label. |
stroke |
none | stroke | function |
none |
Override for codly.highlight.stroke. |
depth |
none | int |
none |
Highlight nesting depth. The renderer derives and replaces this value from span containment. |
Behavior
The constructor and dictionary cast normalize omitted or none bounds to start: 0 and an end bound covering the rest of the line. Explicit bounds must be nonnegative; line must be positive. Character positions start at one and include both endpoints; start: 0 is accepted as a line-start alias. Equal positive bounds select one character. Bounds count the source text after Typst removes the raw block’s common indentation and, for diffs, after the row’s diff marker is removed. Grapheme clusters and whitespace runs remain whole when a boundary falls inside them.
A fill paint is used directly and does not consume a palette entry; a callback receives the next palette paint. Highlights using none also consume the next palette entry. An empty configured palette is invalid. Local style fields override the corresponding codly.highlight settings when provided.
Example: Basic Usage
#import "@preview/codly:2.0.0" as codly
#codly.new(
```js
let answer = 42
```,
highlights: (codly.highlight-config(1, start: 5, end: 10, fill: yellow.lighten(65%), tag: "value"),),
)
Edit & run on your device
The highlighted source and output update after you stop typing. Copy code includes your edits.