Skip to content

Commit

Permalink
Define sys.version and sys.inputs.typst-hs-version.
Browse files Browse the repository at this point in the history
The former is set to the version of typst we are trying to
implement.

The latter is a stringified version number from typst-hs.

This will allow typst programs to tell when they're running
on typst-hs (or pandoc), and react accordingly.

Closes #56.
  • Loading branch information
jgm committed Dec 2, 2024
1 parent 2051ef3 commit 9707b74
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Typst/Module/Standard.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ module Typst.Module.Standard
)
where

import Paths_typst (version)
import Data.Version (showVersion)
import Data.Char (ord, chr)
import Control.Applicative ((<|>))
import Control.Monad (mplus, unless)
Expand Down Expand Up @@ -72,7 +74,11 @@ standardModule =

sysModule :: M.Map Identifier Val
sysModule =
M.fromList [ makeElement (Just "sys") "version" [] ]
M.fromList [ ("version", VVersion [0,12,0])
, ("inputs", VDict (OM.fromList
[("typst-hs-version",
VString (T.pack (showVersion version)))]))
]

symModule :: M.Map Identifier Val
symModule = M.map VSymbol $ makeSymbolMap typstSymbols
Expand Down
1 change: 1 addition & 0 deletions typst.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ library
Typst.Methods
Typst.Util
other-modules:
Paths_typst
Typst.Bind
Typst.Regex
Typst.Show
Expand Down

0 comments on commit 9707b74

Please sign in to comment.