Convert launching preview commands to a single unified command
Myriad-Dreamin opened this issue · comments
Background: In my project, I can provide sys.inputs.at("target")
to control the target of a document. When a target is set to "webpage", it is compiled and suitable for viewing in website. When a target is set to "ebook", it is compiled as a e-book PDF and suitable for viewing in online or offline pdf viewer.
To edit styles for document targeting to "webpage", I want to launch preview with sys.inputs
arguments.
Currently there are four commands to launch preview.
- open
- open in browser
- open with slide mode
- open in browser with slide mode
As feature increased (e.g. sys.inputs
), the matrix becomes larger and unmaintainable. So I want to convert the "open/launch" action into a single command. And create four corresponding auto-detected tasks to replace these commands. The final effect should look like this:
We will have these auto detected tasks (also as a start-up task template):
- open
- open in browser
- open with slide mode
- open in browser with slide mode
And we can invoke a typst-preview.launch
command in task:
{
"version": "2.0.0",
"tasks": [
{
"label": "preview",
"command": "${command:typst-preview.launch}",
"args": {
"openIn": "webview", // v.s. in browser
"mode": "document", // v.s. slide mode
"inputs": {
"target": "webpage",
"theme-setting": "themes/ayu.toml"
}
}
}
]
}
All of arguments in typst-preview.launch
are optional so we can also have a default command to launch without configuration or interactively.
And we can disable auto detected tasks as user preferences.
I think it is ok to have to add custom sys.inputs
. For existing ones, I prefer keeping them instead of replacing them with tasks