What is hash before brackets (#[ ])?

Hi,

From the docs:

This list is affected: #[
  #set list(marker: [--])
  - Dash
]

This one is not:
- Bullet

Hash means Code, brackets mean Markup. The combination isn’t intuitive. What does it mean?

When you are in markup, hash means code, and when you are in code, brackets mean markup.

So when you are in markup, #[ ... ] switches to code and then immediately switches back to markup. Why would you do this? Because [ ... ] also creates a scope for the markup (just like { ... } creates a scope for the code). So #[ ... ] is used in markup to write markup with a limited scope. In this example, the #set list(...) will only affect the next markup line, the rest is out of scope.

1 Like

Thanks! The trick is necessary because without hash I’ll get just literal brackets, and not an invisible scope :blush:

1 Like