#Nested Context Confusion

9 messages · Page 1 of 1 (latest)

charred niche
#

Does a context expression basically "freeze" all content generated up to the point of the expression in order to compute things?
Cuz i dont really understand how nested context expressions work if not something similar described above and would appreciate a cohesive answer.

According to the docs:
"Typst cannot know all the styles that will apply as set rules can be applied to content after it has been constructed. Below, text.lang is already computed when the template function is applied. As such, it cannot possibly be aware of the language change to French in the template."
?render

#let template(body) = {
  set text(lang: "fr")
  upper(body)
}

#set text(lang: "de")
#context [
  #show: template
  #text.lang \
  #context text.lang
]
#

?render
#let template(body) = {
set text(lang: "fr")
upper(body)
}

#set text(lang: "de")
#context [
#show: template
#text.lang
#context text.lang
]

foggy pikeBOT
charred niche
#

?render

#let template(body) = {
  set text(lang: "fr")
  upper(body)
}

#set text(lang: "de")
#context [
  #show: template
  #text.lang \
  #context text.lang
]
charred niche
#

Also im a bit confused as to the description here in the docs for the same section:
"Context blocks can be nested. Contextual code will then always access the innermost context. The example below demonstrates this: The first text.lang will access the outer context block's styles"

To me this perhaps like a bad choice of decriptive words, wouldnt the most appropriate description be that contexual code accesses the context of the closest encapsulating context block?

lost pasture
charred niche