Enter-tainer / typst-preview

[DEPRECATED] Use tinymist instead
https://Enter-tainer.github.io/typst-preview/
MIT License
444 stars 21 forks source link

Pass input arguments to typst world via CLI arguments #213

Closed Myriad-Dreamin closed 5 months ago

Myriad-Dreamin commented 10 months ago

I think it is time to provide a better solution for #134. We can pass a JSON dictionary to typst template now. In most cases, users pass their owned input arguments. In additional, we can have a small set of smart inputs.

Smart input prefer-theme

As a first application, we can pass a smart prefer-theme to typst world.

typst-preview --input prefer-theme="dark"
typst-preview --input prefer-theme="light"
#let my-template(content) = {
  #set text(fill: white) if sys.args.at("prefer-theme") == "dark"
  content
}

Smart input typst-preview

Another candidate argument is a "typst-preview": object containing program information. Indicate whether it is opened form previewing.

E.g. #set text(size: 16pt) if sys.args.at("typst-preview").len() > 0

7sDream commented 5 months ago

As the sys.inputs is added into typst now(at version 0.11.0), do you have any plan to support it?

Enter-tainer commented 5 months ago

it should be supported. but i'm working on important changes in typst/typst recently. so it wont be very fast. pr is also welcome