I have a dictionary with a content block value:
#let meta = (
title: [Free (libre) software]
)
But when I display this dictionary as content using
#meta
(or repr) the content block is displayed as a sequence:
(title: sequence([Free], [ ], [(libre) software]))
I would like to display the dictionary closer to how it has been defined, like
(title: [Free (libre) software])
Is it possible?
Something like
#for (key, value) in meta.pairs() {
[#key: #value]
}
should do the trick, and if you want the parentheses you’ll have to manually place them around the expression.
Yes it could work but I’d like to keep the syntax highlighting if possible. If not I’d consider this option or keeping the sequence.
What syntax highlighting? The only highlighted words in your answer are #let, #meta, and sequence.
If you want to display the dictionary exactly as it was declared in the code, you should use a raw block:
#let dict-definition = ```typst
(title: [Free (libre) software])
```
#dict-definition
You can recover the dictionary using eval:
#let meta = eval(dict-definition.text)
#meta
1 Like
Sorry I should have been clearer: I need to display meta after the fact, without changing its definition from #let meta = (...) to raw and eval.
I don’t need to display the dictionary exactly as it was declared in the code, but I’d like content sequences to appear as joined.
I don’t understand this. If you’re not altering the dictionary dynamically, i.e. changing its definition, why can’t you re-declare it like in the above example? The definition of meta will be identical, there’s just a little bit (3 lines) of overhead. And you can, of course, declare meta before displaying dict-definition.