This code seems like it should work, but instead it applies the dropcap function to “it” instead of the paragraph text. Where am I going wrong?
This example is modified from the closest thing I could find on this forum for what I am trying to do.
#import "@preview/droplet:0.3.1": dropcap
#let head-par-counter = counter("heading-par")
#show heading: it => {
head-par-counter.update(0)
it
head-par-counter.update(it.level)
}
#show par: it => context {
head-par-counter.update(0)
// Note: context is frozen at the start of the context block,
// so .get() below happens before the .update(0) above
let current-level = head-par-counter.get().first()
if current-level > 0 {
dropcap()[it]
} else {
it
}
}
// Sample usage:
#set page(width: 200pt, height: auto, margin: 1cm)
Hello world, this paragraph is not affected
= First
Hello world, this paragraph is replaced by the "it" argument to the drop cap function. I want it to apply the dropcap function to the "H" at the beginning of the paragraph.
== Second
Hello world, this one is the same as the first.
Not affected here! (Not the first paragraph, and this is what I want)