Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace uses of locate(loc => {}) with context expressions #180

Open
2xsaiko opened this issue Jun 30, 2024 · 0 comments
Open

Replace uses of locate(loc => {}) with context expressions #180

2xsaiko opened this issue Jun 30, 2024 · 0 comments

Comments

@2xsaiko
Copy link

2xsaiko commented Jun 30, 2024

locate() with function argument is deprecated. Generally

#let fn() = {
  locate(loc => {
    let value = state.at(loc)

    // ...
  })
}

can be replaced with

#let fn() = context {
  let value = state.get()

  // ...
}

and if you actually need a position reference like the loc parameter, you can use the here() function. https://typst.app/docs/reference/introspection/here/

From https://typst.app/docs/reference/introspection/locate/:

Compatibility

In Typst 0.10 and lower, the locate function took a closure that made the current location in the document available (like here does now). Compatibility with the old way will remain for a while to give package authors time to upgrade. To that effect, locate detects whether it received a selector or a user-defined function and adjusts its semantics accordingly. This behaviour will be removed in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant