Skip to content

Strange behaviour with overlapping highlights #133

Description

@LordBaryhobal

There seems to be an issue with overlapping highlights.
For example:

Image

Notice that for some reason, both highlights start at the beginning of the line and end at the end (though the line is longer than 9 characters). Additionally, the boxes and tags are not displayed in the correct order. The red Inner highlight should be inside the green Outer one.

Another strange case happens when both highlights end on the same character, causing the whole line to disappear completely:

Image

This has been tested with Typst 0.15.0 and Codly 1.3.0

Full test file
#import "@preview/codly:1.3.0": codly, codly-init

#set page(
  width: 20cm,
  height: auto,
  margin: .5cm,
)
#show: codly-init

#let example(code) = {
  table(
    columns: (1fr, .6fr),
    table.header[*Code*][*Result*],
    raw(block: true, lang: "typ", code.text),
    eval(code.text, mode: "markup", scope: (codly: codly)),
  )
}

#example(````
#codly(
  highlights: (
    (line: 1, start: 1, fill: green, tag: [Outer]),
    (line: 1, start: 6, end: 9, fill: red, tag: [Inner]),
  ),
)
```
this is a test
```
````)

#pagebreak()

#example(````
#codly(
  highlights: (
    (line: 1, start: 1, fill: green, tag: [Outer]),
    (line: 1, start: 6, fill: red, tag: [Inner]),
  ),
)
```
this is a test
```
````)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions