Replies: 2 comments
-
Glossary links are just that, links to a label. I don't think it's possible to style links based on the destination, as it is a label. Text cannot be accessed on a label. A convoluted workaround would be to query the glossary heading, and check it against the location of the label. If the label is in the glossary, then style it. |
Beta Was this translation helpful? Give feedback.
-
I think I don't know Typst well enough yet to know how to do what you have suggested. However, I now realise this is a problem that isn't just concerned with this library. For example, I want to make sure that the style I've applied to my web links doesn't get applied to the glossary references. I've managed to put together a bit of a hacky approach though. show link: it => {
if type(it.dest) == "string" {
text(it, fill: blue)
} else {
it
}
}
show ref: it => {
let head = heading
let el = it.element
if el != none and el.func() == heading {
text(fill: red)[#link(el.location())[#it: #el.body]]
} else if el != none and el.func() == figure {
smallcaps(it)
} else {
it
}
} This ensures that only my web links are blue (assuming that their targets will always be strings, and string targets are always web links), and that the glossary links are different to the heading links. It does rely on the fact that the glossary items are figures though, and so I wouldn't be able to have a different style for links to actual figures in the document. If you have any suggestions on how to improve this approach, I'd appreciate it. I'm still pretty new to Typst. |
Beta Was this translation helpful? Give feedback.
-
It's great that there's an example on how to style the links generated by this package.
However, I'd like to be able to style links to the glossary, differently to URLs. Do glossary links have a label on them that can be used to create a more specific show command? Something like
Where
<a>
is a label attached to every glossary reference.Beta Was this translation helpful? Give feedback.
All reactions