codly.sublang
Assigns a syntax-highlighting language to an inclusive range of source lines in a code block.
Signature
codly.sublang(
start: int,
end: int,
lang: str,
)
All fields are required and named. The value can also be supplied as a dictionary.
Fields
| Field | Type | Default / required | Meaning |
|---|---|---|---|
start |
int |
Required, named | First source line of the range, one-based and positive. |
end |
int |
Required, named | Last source line of the range, inclusive and at least start. |
lang |
str |
Required, named | Syntax-highlighting language key. |
Behavior
Pass one or more codly.sublang values in the sublangs argument to codly.new. start must be positive and end at least start; invalid ranges raise an error. Lines outside the ranges keep the raw block’s language. Ranges may also be supplied as dictionaries with the same three fields.
Example: Basic Usage
#import "@preview/codly:2.0.0" as codly
#codly.new(
```sh
echo before
fn answer() {
42
}
echo after
```,
sublangs: (
(start: 2, end: 4, lang: "rs"),
),
)
Edit & run on your device
The highlighted source and output update after you stop typing. Copy code includes your edits.