Skip to content

Annotation Labels not working #85

@JanickLehmann

Description

@JanickLehmann

Hi

While using codly, I noticed that references to annotations are not working.
I tested it with other versions and noticed that it breaks after v1.0.0.

My test setup:

  • Typst v0.13.1 (8ace67d9)
  • codly v1.0.0 / v1.3.0 (working and non-working samples)
  • main.typ with the following content:
#import "@preview/codly:1.0.0": *

#show: codly-init

@test1

#figure(caption: "Test")[
  #codly(
    reference-by: "item",
    annotations: (
      (start: 2, label: <test1>),
    )
  )
  ```py
  print("Hello, world!")

  for i in range(1, 5):
      print(i)

  if i == 3:
      print("Three!")
  ```
] <figure>

This generates the expected output (with some deprecation warnings from Typst):
Image

When switching to v1.3.0 or using the version available on the main branch, compilation fails with the following error:

error: expected label, found auto
     ┌─ @preview/codly:1.3.0\src\lib.typ:1551:16
     │
1551 │             ref(block-label)
     │                 ^^^^^^^^^^^

Additionally, I noticed that references to annotations break, when the annotations start adjacent to each other.
For example, this is working perfectly fine:

#import "@preview/codly:1.0.0": *

#show: codly-init

@test1
@test2

#figure(caption: "Test")[
  #codly(
    reference-by: "item",
    annotations: (
      (start: 2, label: <test1>),
      (start: 4, label: <test2>),
    )
  )
  ```py
  print("Hello, world!")

  for i in range(1, 5):
      print(i)

  if i == 3:
      print("Three!")
  ```
] <figure>

But this will not compile:

#import "@preview/codly:1.0.0": *

#show: codly-init

@test1
@test2

#figure(caption: "Test")[
  #codly(
    reference-by: "item",
    annotations: (
      (start: 2, label: <test1>),
      (start: 3, label: <test2>),
    )
  )
  ```py
  print("Hello, world!")

  for i in range(1, 5):
      print(i)

  if i == 3:
      print("Three!")
  ```
] <figure>

With the following error:

error: label `<test2>` does not exist in the document
  ┌─ main.typ:6:0
  │
6 │ @test2
  │ ^^^^^^

Being able to reference annotations would be of great help in the current document I am writing.
Thanks for taking a look into this and thank you for creating codly!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingurgentThis needs to be fixed ASAP

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions