Hi,
With Typst 0.13.0 a syntax change introduced: A shebang #!
at the very start of a file is now ignored.
Perhaps there’s no use for the shebang right now. How this feature could be used with a compiled language like Typst even in the future?
Hi,
With Typst 0.13.0 a syntax change introduced: A shebang #!
at the very start of a file is now ignored.
Perhaps there’s no use for the shebang right now. How this feature could be used with a compiled language like Typst even in the future?
You can already use it, for example if you have file.typ
with the following content:
#!/path/to/typst compile
Text.
and if you make this file executable, then you can do ./file.typ
and it will compile the PDF.
Note that everything after the executable on the shebang line is taken as a single argument. So if you need to pass additional options to the compiler (e.g. to compile to SVG), you’ll need to write a wrapper script that calls Typst with the right options, and refer to this wrapper script in the shebang line.
If you need more arguments, you can just use env -S
, see env invocation (GNU Coreutils 9.6).
EDIT: for example
#!/bin/env -S /usr/bin/typst compile -f png --pages 1 --open swayimg
I think that might not work as expected on MacOS though as it actually parses the shebang into multiple words? (And what I said in my previous comment was also Linux specific)