Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/args.json
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@
},
"highlights": {
"title": "Highlights",
"description": "You can apply highlights to the code block using the `highlights` argument. It consists of a list of dictionaries, each with the following keys:\n- `line`: the line number to start highlighting\n- `start`: the character position to start highlighting, zero if omitted or `none`\n- `end`: the character position to end highlighting, the end of the line if omitted or `none`\n- `fill`: the fill of the highlight, defaults to the default color\n- `tag`: an optional tag to be displayed alongside the highlight.\n- `inset`: overrides the global @arg-highlight-inset.\n- `baseline`: overrides the baseline which is set by default to the `bottom` component of @arg-highlight-inset.\n- `clip`: overrides the global @arg-highlight-clip.\n- `outset`: overrides the global @arg-highlight-outset.\n- `radius`: overrides the global @arg-highlight-radius.\n- `label`: *if and only if* the code block is in a `figure`, sets the label by which the highlight can be referenced.\n\nAs with other code block settings, annotations are reset after each code block. #one-indexed #zero-indexed",
"description": "You can apply highlights to the code block using the `highlights` argument. It consists of a list of dictionaries, each with the following keys:\n- `line`: the line number to start highlighting\n- `start`: the character position to start highlighting, zero if omitted or `none`\n- `end`: the character position to end highlighting, the end of the line if omitted or `none`\n- `fill`: the fill of the highlight, defaults to the default color\n- `tag`: an optional tag to be displayed alongside the highlight.\n- `inset`: overrides the global @arg-highlight-inset.\n- `baseline`: overrides the highlight box baseline. By default, Typst 0.15 and newer use `auto`; older Typst versions use the `bottom` component of @arg-highlight-inset.\n- `clip`: overrides the global @arg-highlight-clip.\n- `outset`: overrides the global @arg-highlight-outset.\n- `radius`: overrides the global @arg-highlight-radius.\n- `label`: *if and only if* the code block is in a `figure`, sets the label by which the highlight can be referenced.\n\nAs with other code block settings, annotations are reset after each code block. #one-indexed #zero-indexed",
"default": "none",
"ty": [ "array", "type(none)" ],
"function": true,
Expand Down
8 changes: 7 additions & 1 deletion src/lib.typ
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,12 @@
state("codly-highlight-inset", __codly-args.highlight-inset.default).get()
});

let highlight-baseline = if sys.version >= version(0, 15, 0) {
auto
} else {
__codly-inset(highlight-inset).bottom
}

show raw.line.where(label: <codly-highlighted>): codly-line.with(
(__codly-args.highlight-stroke.type_check)(if "highlight-stroke" in extra {
extra.highlight-stroke
Expand All @@ -806,7 +812,7 @@
state("codly-highlight-radius", __codly-args.highlight-radius.default).get()
}),
highlight-inset,
__codly-inset(highlight-inset).bottom,
highlight-baseline,
(__codly-args.highlight-outset.type_check)(if "highlight-outset" in extra {
extra.highlight-outset
} else {
Expand Down
13 changes: 13 additions & 0 deletions tests/issues/131-highlight-baseline-typst-015.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#import "../../codly.typ": *

#show: codly-init.with()

#codly(highlights: (
(line: 3, start: 3, end: 10, fill: orange),
))
```rust
pub fn main() {
println!("Hello, world!");
println!("Hello, world!");
}
```
6 changes: 5 additions & 1 deletion tests/issues/test.typ
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,8 @@ contained within a figure and that figure must have a label.")*/
#codly-reset()

#include "89-nested-highlights.typ"
#codly-reset()
#pagebreak()
#codly-reset()

#include "131-highlight-baseline-typst-015.typ"
#codly-reset()