Something like this would be fine for me
#let nnum(num) = {
strong(text(blue, numbering("①", num)))
}
#codly(
highlight-fill: _ => none,
highlight-stroke: _ => none,
number-format: none,
highlights: (
(line: 1, tag: nnum(1)),
(line: 3, tag: nnum(2)),
),
)
#figure(```
something
more
what is that?
```)
/ #nnum(1): something can be important
/ #nnum(2): this is a question
Andrew
22
So when you say “reference” you just mean display the same number without creating a link like ref
function does?
Anyway, here is the proper reference solution:
Solution
#import "@preview/codly:1.3.0": *
#show: codly-init
#codly(
highlight-fill: _ => none,
highlight-stroke: _ => none,
number-format: none,
highlight-inset: 0pt, // https://github.com/Dherse/codly/issues/81
)
#let raw-count() = counter(figure.where(kind: raw)).get().first()
#let nnum-label(raw-num, n) = label(str(raw-num) + "-" + str(n))
#let nnum(n) = context {
let label = nnum-label(raw-count(), n)
let body = strong(text(0.8em, baseline: 0.1em, blue, numbering("⓵", n)))
link(label, body)
}
#let add-markers(..markers) = context {
let raw-num = raw-count() + 1
let markers = for marker in markers.pos() {
let n = marker.remove("nnum")
((..marker, tag: nnum(n), label: nnum-label(raw-num, n)),)
}
codly(highlights: markers)
}
#let unique-code-block(body) = context {
[#figure(body)#label("code" + str(raw-count() + 1))]
}
#add-markers((line: 2, start: 4, end: 4, nnum: 1), (line: 2, start: 8, nnum: 2))
#unique-code-block(```
code
this that
```)
/ #nnum(1): first
/ #nnum(2): second
#add-markers((line: 1, nnum: 1), (line: 2, nnum: 2), (line: 3, nnum: 3))
#unique-code-block(```
code
wiedahie
dorfkie
```)
/ #nnum(1): first
/ #nnum(2): second
/ #nnum(3): third
1 Like
Yes, this is exactly what I want. Thanks a lot.