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

Can't set document properties based on context #4065

Open
1 task done
frozolotl opened this issue May 3, 2024 · 2 comments
Open
1 task done

Can't set document properties based on context #4065

frozolotl opened this issue May 3, 2024 · 2 comments
Labels
bug Something isn't working styling About set and show rules or style properties

Comments

@frozolotl
Copy link
Contributor

frozolotl commented May 3, 2024

Description

There currently is no way to set any document properties using context-dependent functions.
If one tries to define a show-rule as follows, the PDF export will not have a title set. Using context document.title does still output the set title, though.

// NOTE: You probably don't want to actually do such a `show: body => context …` construction.
#show: body => context {
  set document(title: [Title]) if query(<my-label>).len() == 0
  body
}
#context document.title
// uncomment if desired: <my-label>

Proposal

There should probably be a way to define document properties based on context.

If that is not feasible, then context set document() should throw a compiler error.

Reproduction URL

No response

Operating system

No response

Typst version

  • I am using the latest version of Typst
@frozolotl frozolotl added the bug Something isn't working label May 3, 2024
@Andrew15-5
Copy link
Contributor

Here is the minified version:

#let template(doc) = {
  // context if state("bundle").get() != true {
  context if query(<sub-document-begin>).len() == 0 {
    set document(title: [Title])
  }
  // set ...
  // set ...
  // set ...
  // show ...
  // show ...
  // show ...
  doc
}
#show: template
Text

@laurmaedje laurmaedje added the styling About set and show rules or style properties label May 7, 2024
@Andrew15-5
Copy link
Contributor

Similar issue: #2326.
(set page() inside context vs. set document() (inside if statement that is) inside context)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working styling About set and show rules or style properties
Projects
None yet
Development

No branches or pull requests

3 participants