How to use Typst as Rust Library?

hmm, you can use data loading to configure two different outputs, and then selectively hide different parts of your output. That would probably look something like this:

#show: rest => {
  let mode = sys.inputs.at("mode", default: "all")
  if mode == "text" {
    rest = { show image: hide; rest }
  }
  if mode == "image" {
    rest = { show text: hide; rest }
  }
  rest
}

If the content isn’t so clearly separable by a show rule, you can either “manually” select what to hide for what mode, or try to attach labels to stuff and use show <label> rules.

2 Likes