Using the CLI compiler typt
(0.13.1), I’ve been writing notes about using shell commands on Linux, with syntax highlighting enabled.
Example snippet, to be run by a regular user:
#raw("chmod test.sh", lang: "sh")
Example snippet, to be run by with root privileges:
#raw("chown user test.sh", lang: "sh")
Output screenshot
I would like to include the symbol $
for commands that can be run by regular users and #
for commands that require root privileges at the beginning of each line. (This is a convention used by the Arch Wiki. See this page as an example.)
Now, I’m wondering if it’s possible to do this with correct syntax highlighting. By ‘correct’, I’m thinking of how the Markdown renderer handles it here on Typst forums when a codeblock has the filetype set to shell
or console
instead of sh
:
$ chmod test.sh
# chown user test.sh
I’ve tried changing the lang
option to shell
or console
in Typst, but doing so in disables syntax highlighting for the current raw
block altogether.
Currently, if I want to keep syntax highlighting on, I have to use sh
, where $
is marked as a command and everything after it as arguments:
Example snippet, to be run by a regular user:
#raw("$ chmod test.sh", lang: "sh")
Output screenshot
And #
, together with everything after it, is marked as a comment:
Example snippet, to be run with root privileges:
#raw("# chown user test.sh", lang: "sh")