Enter-tainer / typst-preview

[DEPRECATED] Use tinymist instead

Home Page:https://Enter-tainer.github.io/typst-preview/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pass input arguments to typst world via CLI arguments

Myriad-Dreamin opened this issue · comments

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

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

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