I want the block raw elements to have gray background, and this works fine. But then I try to make one of them to have yellow background instead of gray, and this seems to add another block instead of changing the color of the existing one. How to fix it?
Hello, your first show rule uses a function block.with, and your second show rule is a show-set. They add up, hence the double background.
If you modify the first show rule to be set block(...), then its fine.
The reason why the second works is because raw is already a block element. I am unsure why the docs write it as block.with, but it has the same output for sure.
f.with(a: 1) takes a function f and returns a new function with argument a already set to 1.
There are several types of rules that do different things, see here.
In particular:
#show A: set B(...) is a “show-set” rule, it changes the default B settings for A elements. For example #show raw: set block(fill: luma(240)) sets the default fill for blocks in a raw element.
#show A: f is a “show” rule: it transforms elements A by passing them to the given function. For example #show raw: block.with(fill: luma(240)) is the same as #show raw: it => block(fill: luma(240), it). It wraps the raw element in a new block.
Of course sometimes both methods can be used to get the same visual result.
Hi @jsx97, don’t forget to tick one of the responses if you got a satisfying answer. The answer you choose should usually be the response that you found most correct/helpful/comprehensive for the question you asked. Thanks!