packages feed

typst 0.6.1 → 0.6.2

raw patch · 85 files changed

+441/−235 lines, 85 files

Files

CHANGELOG.md view
@@ -1,5 +1,24 @@ # Revision history for typst-hs +## 0.6.2++  * Allow types to act as constructor functions, as in typst (#61).+    Add new unexported module, Typst.Constructors, defining the+    constructors for each of the typst types.+    Fix name of string type: it is `str`, not `string` (which is only+    the `repr`).++  * Support `dict`, `datetime`, `symbol` constructors.++  * Improve path handling when loading files (#60).+    We now look in the "local path" (the path of the containing file)+    except when the path begins with `/` (in which case it is resolved+    relative to the package path).++  * Fix issue with expression parsing involving labels (#59).++  * Remove spurious trace in `getPath`.+ ## 0.6.1    * Fix precedence for functions (#55).
+ src/Typst/Constructors.hs view
@@ -0,0 +1,132 @@+{-# LANGUAGE LambdaCase #-}+{-# LANGUAGE OverloadedLists #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE RankNTypes #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TupleSections #-}++module Typst.Constructors+  ( getConstructor+  )+where++import qualified Data.Vector as V+import qualified Data.Map.Ordered as OM+import qualified Data.Map as M+import Data.Time (fromGregorian, secondsToDiffTime)+import Data.Maybe (fromMaybe)+import Typst.Types+import Typst.Util (makeFunction, makeFunctionWithScope, namedArg, nthArg, allArgs)+import qualified Data.Set as Set+import Data.Text (Text)+import qualified Data.Text as T+import Typst.Regex (makeRE)+import Data.List (genericTake)+import Control.Monad.Reader (asks)+import Control.Monad (mplus)+import Data.Char (ord, chr)++getConstructor :: ValType -> Maybe Val+getConstructor typ =+  case typ of+    TFloat -> Just $ makeFunction $ VFloat <$> nthArg 1+    TInteger -> Just $ makeFunction $ VInteger <$> nthArg 1+    TRegex -> Just $ makeFunction $ VRegex <$> (nthArg 1 >>= makeRE)+    TVersion -> Just $ makeFunction $ VVersion <$> (asks positional >>= mapM fromVal)+    TString -> Just $ makeFunctionWithScope+      (do+        val <- nthArg 1+        base <- namedArg "base" (10 :: Integer)+        let digitVector :: V.Vector Char+            digitVector = V.fromList $ ['0'..'9'] ++ ['A'..'Z']+        let renderDigit n = digitVector V.!? (fromIntegral n)+        VString <$>+          case val of+            VInteger n | base /= 10+              -> case mDigits base n of+                   Nothing -> fail "Could not convert number to base"+                   Just ds -> maybe+                     (fail "Could not convert number to base")+                     (pure . T.pack)+                     (mapM renderDigit ds)+            _ -> fromVal val `mplus` pure (repr val))+      [ ( "to-unicode",+           makeFunction $ do+             (val :: Text) <- nthArg 1+             case T.uncons val of+               Just (c, t) | T.null t ->+                 pure $ VInteger $ fromIntegral $ ord c+               _ -> fail "to-unicode expects a single character" )+      , ( "from-unicode",+           makeFunction $ do+             (val :: Int) <- nthArg 1+             pure $ VString $ T.pack [chr val] )+      ]+    TLabel -> Just $ makeFunction $ VLabel <$> nthArg 1+    TSymbol -> Just $ makeFunction $ do+        (t :: Text) <- nthArg 1+        vs <- drop 1 <$> allArgs+        variants <-+          mapM+            ( \case+                VArray [VString k, VString v] ->+                  pure (Set.fromList (T.split (== '.') k), v)+                _ -> fail "wrong type in symbol arguments"+            )+            vs+        pure $ VSymbol $ Symbol t False variants+    TDateTime -> Just $ makeFunction $ do+      mbyr <- namedArg "year" Nothing+      mbmo <- namedArg "month" Nothing+      mbda <- namedArg "day" Nothing+      mbhr <- namedArg "hour" Nothing+      mbmn <- namedArg "minute" Nothing+      mbsc <- namedArg "second" Nothing+      let mbday = case (mbyr, mbmo, mbda) of+                     (Nothing, _, _) -> Nothing+                     (Just yr, _, _) -> Just $+                       fromGregorian yr (fromMaybe 1 mbmo) (fromMaybe 1 mbda)+      let mbdifftime = case (mbhr, mbmn, mbsc) of+                              (Nothing, _, _) -> Nothing+                              (Just hr, _, _) -> Just $ secondsToDiffTime $+                                (hr * 60 * 60) + maybe 0 (* 60) mbmn ++                                  fromMaybe 0 mbsc+      pure $ VDateTime mbday mbdifftime+    TDict -> Just $ makeFunction $ do+      a <- nthArg 1+      case a of+        VModule _ m -> pure $ VDict $ OM.fromList $ M.toList m+        _ -> fail "dictionary constructor requires a module as argument"+    TArguments -> Nothing+    -- TODO https://typst.app/docs/reference/foundations/arguments/+    TSelector -> Nothing+    -- TODO https://typst.app/docs/reference/foundations/selector/+    TCounter -> Nothing+    -- TODO https://typst.app/docs/reference/introspection/counter/+    _ -> Nothing+++-- mDigitsRev, mDigits from the unmaintained digits package+-- https://hackage.haskell.org/package/digits-0.3.1+-- (c) 2009-2016 Henry Bucklow, Charlie Harvey -- BSD-3-Clause license.+mDigitsRev :: Integral n+    => n         -- ^ The base to use.+    -> n         -- ^ The number to convert to digit form.+    -> Maybe [n] -- ^ Nothing or Just the digits of the number in list form, in reverse.+mDigitsRev base i = if base < 1+                    then Nothing -- We do not support zero or negative bases+                    else Just $ dr base i+    where+      dr _ 0 = []+      dr b x = case base of+                1 -> genericTake x $ repeat 1+                _ -> let (rest, lastDigit) = quotRem x b+                     in lastDigit : dr b rest++-- | Returns the digits of a positive integer as a Maybe list.+--   or Nothing if a zero or negative base is given+mDigits :: Integral n+    => n -- ^ The base to use.+    -> n -- ^ The number to convert to digit form.+    -> Maybe [n] -- ^ Nothing or Just the digits of the number in list form+mDigits base i = reverse <$> mDigitsRev base i
src/Typst/Evaluate.hs view
@@ -31,6 +31,7 @@ import System.FilePath (replaceFileName, takeBaseName, takeDirectory, (</>)) import Text.Parsec import Typst.Bind (destructuringBind)+import Typst.Constructors (getConstructor) import Typst.Methods (getMethod) import Typst.Module.Standard (loadFileText, standardModule, symModule) import Typst.Module.Math (mathModule)@@ -57,19 +58,21 @@   -- | Markup produced by 'parseTypst'   [Markup] ->   m (Either ParseError Content)-evaluateTypst operations =+evaluateTypst operations fp =   runParserT     (do contents <- mconcat <$> many pContent <* eof         -- "All documents are automatically wrapped in a document element."         pure $ Elt "document" Nothing [("body", VContent contents)])     initialEvalState { evalOperations = operations,-                       evalPackageRoot = "." }+                       evalLocalDir = takeDirectory fp }+    fp  initialEvalState :: EvalState m initialEvalState =   emptyEvalState { evalIdentifiers = [(BlockScope, mempty)]                  , evalMathIdentifiers = [(BlockScope, mathModule <> symModule)]                  , evalStandardIdentifiers = [(BlockScope, standardModule'')]+                 , evalPackageRoot = "."                  }   where     standardModule' = M.insert "eval" evalFunction standardModule@@ -567,6 +570,10 @@           arguments <- toArguments args           applyElementFunction i (Function f) arguments         VFunction Nothing _ (Function f) -> toArguments args >>= f+        VType ty ->+          case getConstructor ty of+            Just (VFunction _ _ (Function f)) -> toArguments args >>= f+            _ -> fail $ "No constructor defined for type " <> show ty         VSymbol (Symbol _ True _) | mathMode ->           do             val' <- lookupIdentifier "accent"@@ -987,7 +994,6 @@ loadModule :: Monad m => Text            -> MP m (Seq Content, (Identifier, M.Map Identifier Val)) loadModule modname = do-  pos <- getPosition   (fp, modid, mbPackageRoot) <-         if T.take 1 modname == "@"            then do@@ -997,13 +1003,7 @@                     (T.pack $ takeWhile (/= ':') . takeBaseName $                        T.unpack modname),                    Just (takeDirectory fp'))-           else if T.take 1 modname == "/" -- refers to path relative to package root-                then do-                  packageRoot <- evalPackageRoot <$> getState-                  pure (packageRoot </> drop 1 (T.unpack modname),-                        Identifier (T.pack $ takeBaseName $ T.unpack modname),-                        Nothing)-                else pure (replaceFileName (sourceName pos) (T.unpack modname),+           else pure (T.unpack modname,                         Identifier (T.pack $ takeBaseName $ T.unpack modname),                         Nothing)   txt <- loadFileText fp@@ -1011,6 +1011,12 @@     Left err -> fail $ show err     Right ms -> do       operations <- evalOperations <$> getState+      currentLocalDir <- evalLocalDir <$> getState+      let (pkgroot , localdir) =+            case mbPackageRoot of+              Just r -> (r , takeDirectory fp)+              Nothing -> (evalPackageRoot initialEvalState ,+                          currentLocalDir </> takeDirectory fp)       res <-         lift $           runParserT@@ -1021,8 +1027,8 @@                 pure (cs, s)             )             initialEvalState{evalOperations = operations,-                             evalPackageRoot = fromMaybe (evalPackageRoot initialEvalState)-                                                   mbPackageRoot }+                             evalLocalDir = localdir,+                             evalPackageRoot = pkgroot }             fp             ms       case res of
src/Typst/Module/Standard.hs view
@@ -15,10 +15,9 @@  import Paths_typst (version) import Data.Version (showVersion)-import Data.Char (ord, chr) import Control.Applicative ((<|>)) import Control.Monad (mplus, unless)-import Control.Monad.Reader (lift, asks)+import Control.Monad.Reader (lift) import qualified Data.Aeson as Aeson import qualified Data.ByteString.Lazy as BL import qualified Data.Csv as Csv@@ -27,7 +26,6 @@ import Data.Maybe (mapMaybe) import Data.Ratio ((%)) import qualified Data.Sequence as Seq-import qualified Data.Set as Set import Data.Text (Text) import qualified Data.Text as T import qualified Data.Text.Encoding as TE@@ -40,12 +38,10 @@ import Typst.Emoji (typstEmojis) import Typst.Module.Calc (calcModule) import Typst.Module.Math (mathModule)-import Typst.Regex (makeRE) import Typst.Symbols (typstSymbols) import Typst.Types import Typst.Util import System.FilePath ((</>))-import Data.List (genericTake) import Data.Time (UTCTime(..)) import Data.Time.Calendar (fromGregorianValid) import Data.Time.Clock (secondsToDiffTime)@@ -301,7 +297,9 @@   , ("alignment", VType TAlignment)   , ("color", VType TColor)   , ("symbol", VType TSymbol)-  , ("string", VType TString)+  , ("str", VType TString)+  , ("label", VType TLabel)+  , ("version", VType TVersion)   ]  colors :: [(Identifier, Val)]@@ -389,9 +387,6 @@       makeFunction $         VColor <$> (CMYK <$> nthArg 1 <*> nthArg 2 <*> nthArg 3 <*> nthArg 4)     ),-    ("float", makeFunction $ VFloat <$> nthArg 1),-    ("int", makeFunction $ VInteger <$> nthArg 1),-    ("label", makeFunction $ VLabel <$> nthArg 1),     ( "counter",       makeFunction $ do         (counter :: Counter) <- nthArg 1@@ -422,7 +417,6 @@                           else end + 1                       )     ),-    ("regex", makeFunction $ VRegex <$> (nthArg 1 >>= makeRE)),     ( "rgb",       makeFunction $         VColor@@ -435,56 +429,6 @@                   <|> (nthArg 1 >>= hexToRGB)               )     ),-    ( "str",-      makeFunctionWithScope-      (do-        val <- nthArg 1-        base <- namedArg "base" (10 :: Integer)-        let digitVector :: V.Vector Char-            digitVector = V.fromList $ ['0'..'9'] ++ ['A'..'Z']-        let renderDigit n = digitVector V.!? (fromIntegral n)-        VString <$>-          case val of-            VInteger n | base /= 10-              -> case mDigits base n of-                   Nothing -> fail "Could not convert number to base"-                   Just ds -> maybe-                     (fail "Could not convert number to base")-                     (pure . T.pack)-                     (mapM renderDigit ds)-            _ -> fromVal val `mplus` pure (repr val))-      [ ( "to-unicode",-           makeFunction $ do-             (val :: Text) <- nthArg 1-             case T.uncons val of-               Just (c, t) | T.null t ->-                 pure $ VInteger $ fromIntegral $ ord c-               _ -> fail "to-unicode expects a single character" )-      , ( "from-unicode",-           makeFunction $ do-             (val :: Int) <- nthArg 1-             pure $ VString $ T.pack [chr val] )-      ]-    ),-    ( "version",-        makeFunction $ do-          xs <- asks positional >>= mapM fromVal-          pure $ VVersion xs-    ),-    ( "symbol",-      makeFunction $ do-        (t :: Text) <- nthArg 1-        vs <- drop 1 <$> allArgs-        variants <--          mapM-            ( \case-                VArray [VString k, VString v] ->-                  pure (Set.fromList (T.split (== '.') k), v)-                _ -> fail "wrong type in symbol arguments"-            )-            vs-        pure $ VSymbol $ Symbol t False variants-    ),     ( "lorem",       makeFunction $ do         (num :: Int) <- nthArg 1@@ -529,17 +473,27 @@ loadFileLazyBytes :: Monad m => FilePath -> MP m BL.ByteString loadFileLazyBytes fp = do   operations <- evalOperations <$> getState-  root <- evalPackageRoot <$> getState-  lift $ BL.fromStrict <$> loadBytes operations (root </> fp)+  path <- getPath fp+  lift $ BL.fromStrict <$> loadBytes operations path  loadFileText :: Monad m => FilePath -> MP m T.Text loadFileText fp = do   operations <- evalOperations <$> getState+  path <- getPath fp+  lift $ TE.decodeUtf8 <$> loadBytes operations path++-- a leading / = relative to package root+getPath :: Monad m => FilePath -> MP m FilePath+getPath ('/':fp') = do   root <- evalPackageRoot <$> getState-  lift $ TE.decodeUtf8 <$> loadBytes operations (root </> fp)+  pure $ root </> fp'+getPath fp = do+  pkgroot <- evalPackageRoot <$> getState+  localdir <- evalLocalDir <$> getState+  pure $ pkgroot </> localdir </> fp  getUTCTime :: Monad m => MP m UTCTime-getUTCTime = (currentUTCTime . evalOperations <$> getState) >>= lift+getUTCTime = getState >>= lift . currentUTCTime . evalOperations  time :: [(Identifier, Val)] time =@@ -658,28 +612,3 @@                  , evalMathIdentifiers = [(BlockScope, mathModule <> symModule)]                  , evalStandardIdentifiers = [(BlockScope, standardModule)]                  }---- mDigitsRev, mDigits from the unmaintained digits package--- https://hackage.haskell.org/package/digits-0.3.1--- (c) 2009-2016 Henry Bucklow, Charlie Harvey -- BSD-3-Clause license.-mDigitsRev :: Integral n-    => n         -- ^ The base to use.-    -> n         -- ^ The number to convert to digit form.-    -> Maybe [n] -- ^ Nothing or Just the digits of the number in list form, in reverse.-mDigitsRev base i = if base < 1-                    then Nothing -- We do not support zero or negative bases-                    else Just $ dr base i-    where-      dr _ 0 = []-      dr b x = case base of-                1 -> genericTake x $ repeat 1-                _ -> let (rest, lastDigit) = quotRem x b-                     in lastDigit : dr b rest---- | Returns the digits of a positive integer as a Maybe list.---   or Nothing if a zero or negative base is given-mDigits :: Integral n-    => n -- ^ The base to use.-    -> n -- ^ The number to convert to digit form.-    -> Maybe [n] -- ^ Nothing or Just the digits of the number in list form-mDigits base i = reverse <$> mDigitsRev base i
src/Typst/Parse.hs view
@@ -713,12 +713,12 @@ pLabel :: P Expr pLabel =   Label . T.pack-    <$> try+    <$> lexeme (try       ( char '<'           *> many1 (satisfy isIdentContinue <|>                     char '_' <|> char '.' <|> char ':')           <* char '>'-      )+      ))  pRef :: P Markup pRef =
src/Typst/Types.hs view
@@ -144,6 +144,7 @@   | VModule Identifier (M.Map Identifier Val)   | VStyles -- just a placeholder for now   | VVersion [Integer]+  -- Types typically have constructors   | VType !ValType   deriving (Show, Eq, Typeable) @@ -618,6 +619,7 @@     evalStyles :: M.Map Identifier Arguments,     evalFlowDirective :: FlowDirective,     evalPackageRoot :: FilePath,+    evalLocalDir :: FilePath,     evalOperations :: Operations m   } @@ -632,6 +634,7 @@       evalStyles = mempty,       evalFlowDirective = FlowNormal,       evalPackageRoot = mempty,+      evalLocalDir = mempty,       evalOperations = undefined     } 
test/Main.hs view
@@ -8,7 +8,7 @@ import qualified Data.Text as T import qualified Data.Text.Encoding as TE import Data.Text.IO as TIO-import System.FilePath (replaceExtension)+import System.FilePath (replaceExtension, joinPath, splitPath) import Test.Tasty (TestTree, Timeout (..), defaultMain, localOption, testGroup) import Test.Tasty.Golden (findByExtension, goldenVsStringDiff) import Text.Show.Pretty (ppShow)@@ -16,7 +16,7 @@ import Typst.Parse (parseTypst) import Typst.Types (Val (VContent), repr, Operations(..)) import Data.Time (getCurrentTime)-import System.Directory (doesFileExist)+import System.Directory (doesFileExist, setCurrentDirectory) import System.Environment (lookupEnv)  main :: IO ()@@ -32,7 +32,8 @@  goldenTests :: IO TestTree goldenTests = do-  inputs <- findByExtension [".typ"] "test/typ"+  setCurrentDirectory "test"+  inputs <- findByExtension [".typ"] "typ"   pure $     localOption (Timeout 1000000 "1s") $       testGroup "golden tests" (map runTest inputs)@@ -42,7 +43,8 @@   goldenVsStringDiff     input     (\ref new -> ["diff", "-u", ref, new])-    ("test/out" <> drop 8 (replaceExtension input ".out"))+    -- remove 'typ/':+    ("out" <> (joinPath . drop 1 . splitPath) (replaceExtension input ".out"))     (writeTest input)  writeTest :: FilePath -> IO BL.ByteString
test/out/compiler/label-01.out view
@@ -74,7 +74,6 @@ , Space , Code     "test/typ/compiler/label-01.typ" ( line 7 , column 4 ) (Label "v")-, Space , Code     "test/typ/compiler/label-01.typ"     ( line 7 , column 9 )@@ -92,6 +91,5 @@                  strong(body: text(body: [A])),                   text(body: [ ]),                   <v>, -                 text(body: [ ]),                   strong(body: text(body: [B])),                   parbreak() })
test/out/compiler/label-03.out view
@@ -66,7 +66,6 @@     "test/typ/compiler/label-03.typ"     ( line 6 , column 9 )     (Label "red")-, Space , Strong [ Text "C" ] , Space , Code@@ -91,7 +90,6 @@                  strong(body: text(body: [B])),                   text(body: [ ]),                   <red>, -                 text(body: [ ]),                   strong(body: text(body: [C])),                   text(body: [ ]),                   <blue>, 
test/out/compiler/show-text-08.out view
@@ -48,7 +48,7 @@        (Just (Literal (String "GRAPH")))        (FuncCall           (Ident (Identifier "image"))-          [ NormalArg (Literal (String "test/assets/files/graph.png")) ]))+          [ NormalArg (Literal (String "/assets/files/graph.png")) ])) , ParBreak , Text "The" , Space@@ -67,6 +67,6 @@ ]),                   parbreak(),                   text(body: [The ]), -                 image(path: "test/assets/files/graph.png"), +                 image(path: "/assets/files/graph.png"),                   text(body: [ has nodes.]),                   parbreak() })
test/out/compute/data-00.out view
@@ -47,7 +47,7 @@        (BasicBind (Just (Identifier "data")))        (FuncCall           (Ident (Identifier "read"))-          [ NormalArg (Literal (String "test/assets/files/hello.txt")) ]))+          [ NormalArg (Literal (String "/assets/files/hello.txt")) ])) , SoftBreak , Code     "test/typ/compute/data-00.typ"
test/out/compute/data-03.out view
@@ -55,7 +55,7 @@        (BasicBind (Just (Identifier "data")))        (FuncCall           (Ident (Identifier "csv"))-          [ NormalArg (Literal (String "test/assets/files/zoo.csv")) ]))+          [ NormalArg (Literal (String "/assets/files/zoo.csv")) ])) , SoftBreak , Code     "test/typ/compute/data-03.typ"
test/out/compute/data-06.out view
@@ -47,7 +47,7 @@        (BasicBind (Just (Identifier "data")))        (FuncCall           (Ident (Identifier "json"))-          [ NormalArg (Literal (String "test/assets/files/zoo.json")) ]))+          [ NormalArg (Literal (String "/assets/files/zoo.json")) ])) , SoftBreak , Code     "test/typ/compute/data-06.typ"
test/out/compute/data-08.out view
@@ -47,7 +47,7 @@        (BasicBind (Just (Identifier "data")))        (FuncCall           (Ident (Identifier "toml"))-          [ NormalArg (Literal (String "test/assets/files/toml-types.toml"))+          [ NormalArg (Literal (String "/assets/files/toml-types.toml"))           ])) , SoftBreak , Code
test/out/compute/data-10.out view
@@ -47,7 +47,7 @@        (BasicBind (Just (Identifier "data")))        (FuncCall           (Ident (Identifier "yaml"))-          [ NormalArg (Literal (String "test/assets/files/yaml-types.yaml"))+          [ NormalArg (Literal (String "/assets/files/yaml-types.yaml"))           ])) , SoftBreak , Code
test/out/compute/data-12.out view
@@ -47,7 +47,7 @@        (BasicBind (Just (Identifier "data")))        (FuncCall           (Ident (Identifier "xml"))-          [ NormalArg (Literal (String "test/assets/files/data.xml")) ]))+          [ NormalArg (Literal (String "/assets/files/data.xml")) ])) , SoftBreak , Code     "test/typ/compute/data-12.typ"
test/out/layout/grid-3-01.out view
@@ -73,7 +73,7 @@               , NormalArg                   (FuncCall                      (Ident (Identifier "image"))-                     [ NormalArg (Literal (String "test/assets/files/rhino.png")) ])+                     [ NormalArg (Literal (String "/assets/files/rhino.png")) ])               ])        , NormalArg            (FuncCall@@ -108,7 +108,7 @@                  text(body: [ ]),                   grid(children: (align(alignment: top, -                                       body: image(path: "test/assets/files/rhino.png")), +                                       body: image(path: "/assets/files/rhino.png")),                                   align(alignment: top,                                         body: rect(body: align(alignment: right,                                                                body: text(body: [LoL])), 
test/out/layout/pad-02.out view
@@ -65,7 +65,7 @@        , NormalArg            (FuncCall               (Ident (Identifier "image"))-              [ NormalArg (Literal (String "test/assets/files/tiger.jpg")) ])+              [ NormalArg (Literal (String "/assets/files/tiger.jpg")) ])        ]) , SoftBreak , Code@@ -87,7 +87,7 @@                        body: text(body: [Before])),                   text(body: [ ]), -                 pad(body: image(path: "test/assets/files/tiger.jpg"), +                 pad(body: image(path: "/assets/files/tiger.jpg"),                       rest: 10.0pt),                   text(body: [ ]), 
test/out/layout/par-bidi-06.out view
@@ -56,7 +56,7 @@        [ NormalArg            (FuncCall               (Ident (Identifier "image"))-              [ NormalArg (Literal (String "test/assets/files/rhino.png"))+              [ NormalArg (Literal (String "/assets/files/rhino.png"))               , KeyValArg (Identifier "height") (Literal (Numeric 11.0 Pt))               ])        ])@@ -70,7 +70,7 @@ קרנפיםRh],                        lang: "he"),                   box(body: image(height: 11.0pt, -                                 path: "test/assets/files/rhino.png")), +                                 path: "/assets/files/rhino.png")),                   text(body: [inoחיים],                        lang: "he"),                   parbreak() })
test/out/layout/par-indent-00.out view
@@ -97,7 +97,7 @@        [ NormalArg            (FuncCall               (Ident (Identifier "image"))-              [ NormalArg (Literal (String "test/assets/files/tiger.jpg"))+              [ NormalArg (Literal (String "/assets/files/tiger.jpg"))               , KeyValArg (Identifier "height") (Literal (Numeric 6.0 Pt))               ])        ])@@ -124,7 +124,7 @@        , NormalArg            (FuncCall               (Ident (Identifier "image"))-              [ NormalArg (Literal (String "test/assets/files/rhino.png"))+              [ NormalArg (Literal (String "/assets/files/rhino.png"))               , KeyValArg (Identifier "width") (Literal (Numeric 1.0 Cm))               ])        ])@@ -223,12 +223,12 @@                  text(body: [But the second one does.]),                   parbreak(),                   box(body: image(height: 6.0pt, -                                 path: "test/assets/files/tiger.jpg")), +                                 path: "/assets/files/tiger.jpg")),                   text(body: [ starts a paragraph, also with indent.]),                   parbreak(),                   align(alignment: center, -                       body: image(path: "test/assets/files/rhino.png", +                       body: image(path: "/assets/files/rhino.png",                                     width: 1.0cm)),                   parbreak(),                   heading(body: text(body: [Headings]), 
test/out/layout/place-00.out view
@@ -65,7 +65,7 @@        , NormalArg            (FuncCall               (Ident (Identifier "image"))-              [ NormalArg (Literal (String "test/assets/files/tiger.jpg"))+              [ NormalArg (Literal (String "/assets/files/tiger.jpg"))               , KeyValArg (Identifier "width") (Literal (Numeric 1.8 Cm))               ])        ])@@ -197,7 +197,7 @@                  heading(body: text(body: [Placement]),                           level: 1),                   place(alignment: right, -                       body: image(path: "test/assets/files/tiger.jpg", +                       body: image(path: "/assets/files/tiger.jpg",                                     width: 1.8cm)),                   text(body: [ Hi there. This is ]), 
test/out/layout/transform-01.out view
@@ -65,7 +65,7 @@                      , NormalArg                          (FuncCall                             (Ident (Identifier "image"))-                            [ NormalArg (Literal (String "test/assets/files/tiger.jpg")) ])+                            [ NormalArg (Literal (String "/assets/files/tiger.jpg")) ])                      ])               ])        ])@@ -78,6 +78,6 @@ ]),                   align(alignment: Axes(center, horizon),                         body: rotate(angle: 20.0deg, -                                    body: scale(body: image(path: "test/assets/files/tiger.jpg"), +                                    body: scale(body: image(path: "/assets/files/tiger.jpg"),                                                  factor: 70%))),                   parbreak() })
test/out/layout/transform-02.out view
@@ -52,7 +52,7 @@        , NormalArg            (FuncCall               (Ident (Identifier "image"))-              [ NormalArg (Literal (String "test/assets/files/tiger.jpg"))+              [ NormalArg (Literal (String "/assets/files/tiger.jpg"))               , KeyValArg (Identifier "width") (Literal (Numeric 50.0 Percent))               ])        ])@@ -62,7 +62,7 @@ document(body: { text(body: [ ]),                   rotate(angle: 10.0deg, -                        body: image(path: "test/assets/files/tiger.jpg", +                        body: image(path: "/assets/files/tiger.jpg",                                      width: 50%),                          origin: Axes(left, top)),                   parbreak() })
test/out/math/content-00.out view
@@ -51,7 +51,7 @@           , NormalArg               (FuncCall                  (Ident (Identifier "image"))-                 [ NormalArg (Literal (String "test/assets/files/monkey.svg"))+                 [ NormalArg (Literal (String "/assets/files/monkey.svg"))                  , KeyValArg (Identifier "height") (Literal (Numeric 1.0 Em))                  ])           ]))@@ -109,7 +109,7 @@                                        text(body: [+]),                                         math.frac(denom: text(body: [2]),                                                   num: move(body: image(height: 1.0em, -                                                                       path: "test/assets/files/monkey.svg"), +                                                                       path: "/assets/files/monkey.svg"),                                                             dy: 0.2em)) },                                 numbering: none),                   parbreak() })
test/out/meta/counter-01.out view
@@ -44,11 +44,6 @@     "test/typ/meta/counter-01.typ"     ( line 3 , column 2 )     (Let (BasicBind (Just (Identifier "label"))) (Label "heya"))-, Space-, Code-    "test/typ/meta/counter-01.typ"-    ( line 3 , column 14 )-    (Label "heya") , SoftBreak , Code     "test/typ/meta/counter-01.typ"@@ -112,8 +107,6 @@ --- evaluated --- document(body: { text(body: [ ]), -                 text(body: [ ]), -                 <heya>,                   text(body: [ ]),                   text(body: [
test/out/meta/figure-00.out view
@@ -122,7 +122,7 @@               , NormalArg                   (FuncCall                      (Ident (Identifier "image"))-                     [ NormalArg (Literal (String "test/assets/files/cylinder.svg"))+                     [ NormalArg (Literal (String "/assets/files/cylinder.svg"))                      , KeyValArg (Identifier "height") (Literal (Numeric 2.0 Cm))                      ])               ])@@ -204,7 +204,7 @@                  <tab-basic>,                   parbreak(),                   figure(body: pad(body: image(height: 2.0cm, -                                              path: "test/assets/files/cylinder.svg"), +                                              path: "/assets/files/cylinder.svg"),                                    y: -6.0pt),                          caption: text(body: [The basic shapes.]),                          numbering: "I"), 
test/out/meta/figure-01.out view
@@ -54,7 +54,7 @@               , NormalArg                   (FuncCall                      (Ident (Identifier "image"))-                     [ NormalArg (Literal (String "test/assets/files/cylinder.svg")) ])+                     [ NormalArg (Literal (String "/assets/files/cylinder.svg")) ])               ])        , KeyValArg            (Identifier "caption")@@ -70,7 +70,7 @@ --- evaluated --- document(body: { parbreak(),                   figure(body: table(children: (text(body: [Second cylinder]), -                                               image(path: "test/assets/files/cylinder.svg")), +                                               image(path: "/assets/files/cylinder.svg")),                                      columns: 2),                          caption: "A table containing images."),                   text(body: [ ]), 
test/out/meta/footnote-container-00.out view
@@ -62,7 +62,7 @@        [ NormalArg            (FuncCall               (Ident (Identifier "image"))-              [ NormalArg (Literal (String "test/assets/files/graph.png"))+              [ NormalArg (Literal (String "/assets/files/graph.png"))               , KeyValArg (Identifier "width") (Literal (Numeric 70.0 Percent))               ])        , KeyValArg@@ -141,7 +141,7 @@                                      dest: "https://typst.app/docs")),                   text(body: [! ]), -                 figure(body: image(path: "test/assets/files/graph.png", +                 figure(body: image(path: "/assets/files/graph.png",                                      width: 70%),                          caption: { text(body: [ A graph ]), 
@@ -69,7 +69,7 @@                                 , NormalArg                                     (FuncCall                                        (Ident (Identifier "image"))-                                       [ NormalArg (Literal (String "test/assets/files/rhino.png"))+                                       [ NormalArg (Literal (String "/assets/files/rhino.png"))                                        , KeyValArg (Identifier "width") (Literal (Numeric 1.0 Cm))                                        ])                                 ])@@ -86,7 +86,7 @@                  link(body: block(body: { text(body: [ My cool rhino ]), -                                          box(body: move(body: image(path: "test/assets/files/rhino.png", +                                          box(body: move(body: image(path: "/assets/files/rhino.png",                                                                       width: 1.0cm),                                                           dx: 10.0pt)),                                            parbreak() }), 
test/out/meta/query-figure-00.out view
@@ -182,7 +182,7 @@        [ NormalArg            (FuncCall               (Ident (Identifier "image"))-              [ NormalArg (Literal (String "test/assets/files/glacier.jpg")) ])+              [ NormalArg (Literal (String "/assets/files/glacier.jpg")) ])        , KeyValArg            (Identifier "caption")            (Block (Content [ Text "Glacier" , Space , Text "melting" ]))@@ -225,7 +225,7 @@        [ NormalArg            (FuncCall               (Ident (Identifier "image"))-              [ NormalArg (Literal (String "test/assets/files/tiger.jpg")) ])+              [ NormalArg (Literal (String "/assets/files/tiger.jpg")) ])        , KeyValArg            (Identifier "caption")            (Block (Content [ Text "Tiger" , Space , Text "world" ]))@@ -243,7 +243,7 @@                          level: 1),                   locate(func: ),                   parbreak(), -                 figure(body: image(path: "test/assets/files/glacier.jpg"), +                 figure(body: image(path: "/assets/files/glacier.jpg"),                          caption: text(body: [Glacier melting]),                          numbering: "I"),                   parbreak(), @@ -253,7 +253,7 @@                         numbering: "I",                          supplement: "Figure"),                   parbreak(), -                 figure(body: image(path: "test/assets/files/tiger.jpg"), +                 figure(body: image(path: "/assets/files/tiger.jpg"),                          caption: text(body: [Tiger world]),                          numbering: "I"),                   parbreak() })
test/out/meta/ref-03.out view
@@ -111,7 +111,7 @@        [ NormalArg            (FuncCall               (Ident (Identifier "image"))-              [ NormalArg (Literal (String "test/assets/files/cylinder.svg"))+              [ NormalArg (Literal (String "/assets/files/cylinder.svg"))               , KeyValArg (Identifier "height") (Literal (Numeric 3.0 Cm))               ])        , KeyValArg@@ -131,7 +131,7 @@        [ NormalArg            (FuncCall               (Ident (Identifier "image"))-              [ NormalArg (Literal (String "test/assets/files/tiger.jpg"))+              [ NormalArg (Literal (String "/assets/files/tiger.jpg"))               , KeyValArg (Identifier "height") (Literal (Numeric 3.0 Cm))               ])        , KeyValArg
+ test/out/regression/issue59.out view
@@ -0,0 +1,56 @@+--- parse tree ---+[ Code+    "test/typ/regression/issue59.typ"+    ( line 1 , column 2 )+    (Let+       (BasicBind (Just (Identifier "test")))+       (FuncExpr+          [ NormalParam (Identifier "x") , NormalParam (Identifier "y") ]+          (Block+             (CodeBlock+                [ If+                    [ ( Equals (Ident (Identifier "x")) (Ident (Identifier "y"))+                      , Block (Content [ Text "\9989" ])+                      )+                    , ( Literal (Boolean True)+                      , Block+                          (Content+                             [ Text "\10060"+                             , Text "("+                             , Code+                                 "test/typ/regression/issue59.typ"+                                 ( line 1 , column 47 )+                                 (FuncCall+                                    (Ident (Identifier "repr"))+                                    [ NormalArg (Ident (Identifier "x")) ])+                             , Space+                             , Text "/"+                             , Text "="+                             , Space+                             , Code+                                 "test/typ/regression/issue59.typ"+                                 ( line 1 , column 59 )+                                 (FuncCall+                                    (Ident (Identifier "repr"))+                                    [ NormalArg (Ident (Identifier "y")) ])+                             , Text ")"+                             ])+                      )+                    ]+                ]))))+, SoftBreak+, Code+    "test/typ/regression/issue59.typ"+    ( line 2 , column 2 )+    (If+       [ ( Not (Equals (Literal (Int 5)) (Label "foo"))+         , Block (CodeBlock [ Block (Content [ Text "a" ]) ])+         )+       ])+, ParBreak+]+--- evaluated ---+document(body: { text(body: [+]), +                 text(body: [a]), +                 parbreak() })
+ test/out/regression/issue60.out view
@@ -0,0 +1,62 @@+--- parse tree ---+[ Code+    "typ/regression/issue60.typ"+    ( line 1 , column 2 )+    (Let+       (BasicBind (Just (Identifier "test")))+       (FuncExpr+          [ NormalParam (Identifier "x") , NormalParam (Identifier "y") ]+          (Block+             (CodeBlock+                [ If+                    [ ( Equals (Ident (Identifier "x")) (Ident (Identifier "y"))+                      , Block (Content [ Text "\9989" ])+                      )+                    , ( Literal (Boolean True)+                      , Block+                          (Content+                             [ Text "\10060"+                             , Text "("+                             , Code+                                 "typ/regression/issue60.typ"+                                 ( line 1 , column 47 )+                                 (FuncCall+                                    (Ident (Identifier "repr"))+                                    [ NormalArg (Ident (Identifier "x")) ])+                             , Space+                             , Text "/"+                             , Text "="+                             , Space+                             , Code+                                 "typ/regression/issue60.typ"+                                 ( line 1 , column 59 )+                                 (FuncCall+                                    (Ident (Identifier "repr"))+                                    [ NormalArg (Ident (Identifier "y")) ])+                             , Text ")"+                             ])+                      )+                    ]+                ]))))+, SoftBreak+, Code+    "typ/regression/issue60.typ"+    ( line 2 , column 2 )+    (Import+       (Literal (String "addons/example.typ"))+       (SomeIdentifiers [ ( Identifier "utf8string" , Nothing ) ]))+, SoftBreak+, Code+    "typ/regression/issue60.typ"+    ( line 3 , column 2 )+    (Ident (Identifier "utf8string"))+, ParBreak+]+--- evaluated ---+document(body: { text(body: [+]), +                 text(body: [+]), +                 text(body: [Anything!+]), +                 parbreak() })
test/out/text/baseline-00.out view
@@ -151,7 +151,7 @@        , NormalArg            (FuncCall               (Ident (Identifier "image"))-              [ NormalArg (Literal (String "test/assets/files/tiger.jpg"))+              [ NormalArg (Literal (String "/assets/files/tiger.jpg"))               , KeyValArg (Identifier "width") (Literal (Numeric 1.5 Cm))               ])        ])@@ -187,7 +187,7 @@                  text(body: [— Hey ]),                   box(baseline: 40%, -                     body: image(path: "test/assets/files/tiger.jpg", +                     body: image(path: "/assets/files/tiger.jpg",                                   width: 1.5cm)),                   text(body: [ there!]),                   parbreak() })
test/out/visualize/image-00.out view
@@ -47,7 +47,7 @@     ( line 5 , column 2 )     (FuncCall        (Ident (Identifier "image"))-       [ NormalArg (Literal (String "test/assets/files/rhino.png")) ])+       [ NormalArg (Literal (String "/assets/files/rhino.png")) ]) , ParBreak , Comment , Code@@ -62,7 +62,7 @@     ( line 9 , column 2 )     (FuncCall        (Ident (Identifier "image"))-       [ NormalArg (Literal (String "test/assets/files/tiger.jpg")) ])+       [ NormalArg (Literal (String "/assets/files/tiger.jpg")) ]) , ParBreak ] --- evaluated ---@@ -70,9 +70,9 @@ ]),                   text(body: [ ]), -                 image(path: "test/assets/files/rhino.png"), +                 image(path: "/assets/files/rhino.png"),                   parbreak(),                   text(body: [ ]), -                 image(path: "test/assets/files/tiger.jpg"), +                 image(path: "/assets/files/tiger.jpg"),                   parbreak() })
test/out/visualize/image-01.out view
@@ -50,7 +50,7 @@        [ NormalArg            (FuncCall               (Ident (Identifier "image"))-              [ NormalArg (Literal (String "test/assets/files/rhino.png"))+              [ NormalArg (Literal (String "/assets/files/rhino.png"))               , KeyValArg (Identifier "width") (Literal (Numeric 30.0 Pt))               ])        ])@@ -63,7 +63,7 @@        [ NormalArg            (FuncCall               (Ident (Identifier "image"))-              [ NormalArg (Literal (String "test/assets/files/rhino.png"))+              [ NormalArg (Literal (String "/assets/files/rhino.png"))               , KeyValArg (Identifier "height") (Literal (Numeric 30.0 Pt))               ])        ])@@ -74,7 +74,7 @@     ( line 9 , column 2 )     (FuncCall        (Ident (Identifier "image"))-       [ NormalArg (Literal (String "test/assets/files/monkey.svg"))+       [ NormalArg (Literal (String "/assets/files/monkey.svg"))        , KeyValArg (Identifier "width") (Literal (Numeric 100.0 Percent))        , KeyValArg (Identifier "height") (Literal (Numeric 20.0 Pt))        , KeyValArg (Identifier "fit") (Literal (String "stretch"))@@ -91,7 +91,7 @@        , NormalArg            (FuncCall               (Ident (Identifier "image"))-              [ NormalArg (Literal (String "test/assets/files/tiger.jpg"))+              [ NormalArg (Literal (String "/assets/files/tiger.jpg"))               , KeyValArg (Identifier "width") (Literal (Numeric 40.0 Pt))               , KeyValArg (Identifier "alt") (Literal (String "A tiger"))               ])@@ -103,20 +103,20 @@ ]),                   text(body: [ ]), -                 box(body: image(path: "test/assets/files/rhino.png", +                 box(body: image(path: "/assets/files/rhino.png",                                   width: 30.0pt)),                   text(body: [ ]),                   box(body: image(height: 30.0pt, -                                 path: "test/assets/files/rhino.png")), +                                 path: "/assets/files/rhino.png")),                   parbreak(),                   image(fit: "stretch",                         height: 20.0pt, -                       path: "test/assets/files/monkey.svg", +                       path: "/assets/files/monkey.svg",                         width: 100%),                   parbreak(),                   align(alignment: Axes(right, bottom),                         body: image(alt: "A tiger", -                                   path: "test/assets/files/tiger.jpg", +                                   path: "/assets/files/tiger.jpg",                                     width: 40.0pt)),                   parbreak() })
test/out/visualize/image-02.out view
@@ -66,7 +66,7 @@        , NormalArg            (FuncCall               (Ident (Identifier "image"))-              [ NormalArg (Literal (String "test/assets/files/tiger.jpg"))+              [ NormalArg (Literal (String "/assets/files/tiger.jpg"))               , KeyValArg (Identifier "width") (Literal (Numeric 100.0 Percent))               , KeyValArg (Identifier "height") (Literal (Numeric 100.0 Percent))               , KeyValArg (Identifier "fit") (Literal (String "contain"))@@ -74,7 +74,7 @@        , NormalArg            (FuncCall               (Ident (Identifier "image"))-              [ NormalArg (Literal (String "test/assets/files/tiger.jpg"))+              [ NormalArg (Literal (String "/assets/files/tiger.jpg"))               , KeyValArg (Identifier "width") (Literal (Numeric 100.0 Percent))               , KeyValArg (Identifier "height") (Literal (Numeric 100.0 Percent))               , KeyValArg (Identifier "fit") (Literal (String "cover"))@@ -82,7 +82,7 @@        , NormalArg            (FuncCall               (Ident (Identifier "image"))-              [ NormalArg (Literal (String "test/assets/files/monkey.svg"))+              [ NormalArg (Literal (String "/assets/files/monkey.svg"))               , KeyValArg (Identifier "width") (Literal (Numeric 100.0 Percent))               , KeyValArg (Identifier "height") (Literal (Numeric 100.0 Percent))               , KeyValArg (Identifier "fit") (Literal (String "stretch"))@@ -97,15 +97,15 @@ ]),                   grid(children: (image(fit: "contain",                                         height: 100%, -                                       path: "test/assets/files/tiger.jpg", +                                       path: "/assets/files/tiger.jpg",                                         width: 100%),                                   image(fit: "cover",                                         height: 100%, -                                       path: "test/assets/files/tiger.jpg", +                                       path: "/assets/files/tiger.jpg",                                         width: 100%),                                   image(fit: "stretch",                                         height: 100%, -                                       path: "test/assets/files/monkey.svg", +                                       path: "/assets/files/monkey.svg",                                         width: 100%)),                        columns: (1.0fr,                                  1.0fr, 
test/out/visualize/image-03.out view
@@ -54,7 +54,7 @@     ( line 5 , column 2 )     (FuncCall        (Ident (Identifier "image"))-       [ NormalArg (Literal (String "test/assets/files/rhino.png")) ])+       [ NormalArg (Literal (String "/assets/files/rhino.png")) ]) , ParBreak ] --- evaluated ---@@ -63,5 +63,5 @@                  text(body: [ Stuff ]), -                 image(path: "test/assets/files/rhino.png"), +                 image(path: "/assets/files/rhino.png"),                   parbreak() })
test/out/visualize/image-04.out view
@@ -50,7 +50,7 @@        [ NormalArg            (FuncCall               (Ident (Identifier "image"))-              [ NormalArg (Literal (String "test/assets/files/tiger.jpg"))+              [ NormalArg (Literal (String "/assets/files/tiger.jpg"))               , KeyValArg (Identifier "height") (Literal (Numeric 1.0 Cm))               , KeyValArg (Identifier "width") (Literal (Numeric 80.0 Percent))               ])@@ -64,7 +64,7 @@ ]),                   text(body: [A ]),                   box(body: image(height: 1.0cm, -                                 path: "test/assets/files/tiger.jpg", +                                 path: "/assets/files/tiger.jpg",                                   width: 80%)),                   text(body: [ B]),                   parbreak() })
test/out/visualize/image-05.out view
@@ -45,11 +45,11 @@     ( line 3 , column 2 )     (FuncCall        (Ident (Identifier "image"))-       [ NormalArg (Literal (String "test/assets/files/pattern.svg")) ])+       [ NormalArg (Literal (String "/assets/files/pattern.svg")) ]) , ParBreak ] --- evaluated --- document(body: { text(body: [ ]), -                 image(path: "test/assets/files/pattern.svg"), +                 image(path: "/assets/files/pattern.svg"),                   parbreak() })
test/out/visualize/svg-text-00.out view
@@ -54,7 +54,7 @@        [ NormalArg            (FuncCall               (Ident (Identifier "image"))-              [ NormalArg (Literal (String "test/assets/files/diagram.svg")) ])+              [ NormalArg (Literal (String "/assets/files/diagram.svg")) ])        , KeyValArg            (Identifier "caption")            (Block@@ -67,6 +67,6 @@ document(body: { text(body: [ ]),                   parbreak(), -                 figure(body: image(path: "test/assets/files/diagram.svg"), +                 figure(body: image(path: "/assets/files/diagram.svg"),                          caption: text(body: [A textful diagram])),                   parbreak() })
test/typ/compiler/show-text-08.typ view
@@ -1,5 +1,5 @@ // Test absolute path in layout phase. -#show "GRAPH": image("test/assets/files/graph.png")+#show "GRAPH": image("/assets/files/graph.png")  The GRAPH has nodes.
test/typ/compute/data-00.typ view
@@ -1,4 +1,4 @@ // Test reading plain text files-#let data = read("test/assets/files/hello.txt")+#let data = read("/assets/files/hello.txt") #test(data, "Hello, world!") 
test/typ/compute/data-01.typ view
@@ -1,3 +1,3 @@ // Error: 18-32 file not found (searched at /missing.txt)-#let data = read("test/assets/files/missing.txt")+#let data = read("/assets/files/missing.txt") 
test/typ/compute/data-02.typ view
@@ -1,3 +1,3 @@ // Error: 18-28 file is not valid utf-8-#let data = read("test/assets/files/bad.txt")+#let data = read("/assets/files/bad.txt") 
test/typ/compute/data-03.typ view
@@ -1,7 +1,7 @@ // Test reading CSV data. // Ref: true #set page(width: auto)-#let data = csv("test/assets/files/zoo.csv")+#let data = csv("/assets/files/zoo.csv") #let cells = data.at(0).map(strong) + data.slice(1).flatten() #table(columns: data.at(0).len(), ..cells) 
test/typ/compute/data-05.typ view
@@ -1,3 +1,3 @@ // Error: 6-16 failed to parse csv file: found 3 instead of 2 fields in line 3-#csv("test/assets/files/bad.csv")+#csv("/assets/files/bad.csv") 
test/typ/compute/data-06.typ view
@@ -1,5 +1,5 @@ // Test reading JSON data.-#let data = json("test/assets/files/zoo.json")+#let data = json("/assets/files/zoo.json") #test(data.len(), 3) #test(data.at(0).name, "Debby") #test(data.at(2).weight, 150)
test/typ/compute/data-07.typ view
@@ -1,3 +1,3 @@ // Error: 7-18 failed to parse json file: syntax error in line 3-#json("test/assets/files/bad.json")+#json("/assets/files/bad.json") 
test/typ/compute/data-08.typ view
@@ -1,5 +1,5 @@ // Test reading TOML data.-#let data = toml("test/assets/files/toml-types.toml")+#let data = toml("/assets/files/toml-types.toml") #test(data.string, "wonderful") #test(data.integer, 42) #test(data.float, 3.14)
test/typ/compute/data-09.typ view
@@ -1,3 +1,3 @@ // Error: 7-18 failed to parse toml file: expected `.`, `=`, index 15-15-#toml("test/assets/files/bad.toml")+#toml("/assets/files/bad.toml") 
test/typ/compute/data-10.typ view
@@ -1,5 +1,5 @@ // Test reading YAML data-#let data = yaml("test/assets/files/yaml-types.yaml")+#let data = yaml("/assets/files/yaml-types.yaml") #test(data.len(), 7) #test(data.null_key, (none, none)) #test(data.string, "text")
test/typ/compute/data-11.typ view
@@ -1,3 +1,3 @@ // Error: 7-18 failed to parse yaml file: while parsing a flow sequence, expected ',' or ']' at line 2 column 1-#yaml("test/assets/files/bad.yaml")+#yaml("/assets/files/bad.yaml") 
test/typ/compute/data-12.typ view
@@ -1,5 +1,5 @@ // Test reading XML data.-#let data = xml("test/assets/files/data.xml")+#let data = xml("/assets/files/data.xml") #test(data, ((   tag: "data",   attrs: (:),
test/typ/compute/data-13.typ view
@@ -1,2 +1,2 @@ // Error: 6-16 failed to parse xml file: found closing tag 'data' instead of 'hello' in line 3-#xml("test/assets/files/bad.xml")+#xml("/assets/files/bad.xml")
test/typ/compute/foundations-20.typ view
@@ -2,6 +2,6 @@ #show raw: it => eval(it.text)  ```-image("test/assets/files/tiger.jpg")+image("/assets/files/tiger.jpg") ``` 
test/typ/compute/foundations-21.typ view
@@ -2,7 +2,7 @@ #show raw: it => eval("[" + it.text + "]")  ```-#show emph: _ => image("test/assets/files/giraffe.jpg")+#show emph: _ => image("/assets/files/giraffe.jpg") _No relative giraffe!_ ``` 
test/typ/layout/grid-3-01.typ view
@@ -5,7 +5,7 @@   columns: 4 * (1fr,),   row-gutter: 10pt,   column-gutter: (0pt, 10%),-  align(top, image("test/assets/files/rhino.png")),+  align(top, image("/assets/files/rhino.png")),   align(top, rect(inset: 0pt, fill: eastern, align(right)[LoL])),   [rofl],   [\ A] * 3,
test/typ/layout/pad-02.typ view
@@ -1,6 +1,6 @@ // Test that the pad element doesn't consume the whole region. #set page(height: 6cm) #align(left)[Before]-#pad(10pt, image("test/assets/files/tiger.jpg"))+#pad(10pt, image("/assets/files/tiger.jpg")) #align(right)[After] 
test/typ/layout/par-bidi-06.typ view
@@ -1,4 +1,4 @@ // Test inline object. #set text(lang: "he")-קרנפיםRh#box(image("test/assets/files/rhino.png", height: 11pt))inoחיים+קרנפיםRh#box(image("/assets/files/rhino.png", height: 11pt))inoחיים 
test/typ/layout/par-indent-00.typ view
@@ -6,10 +6,10 @@  But the second one does. -#box(image("test/assets/files/tiger.jpg", height: 6pt))+#box(image("/assets/files/tiger.jpg", height: 6pt)) starts a paragraph, also with indent. -#align(center, image("test/assets/files/rhino.png", width: 1cm))+#align(center, image("/assets/files/rhino.png", width: 1cm))  = Headings - And lists.
test/typ/layout/place-00.typ view
@@ -2,7 +2,7 @@ #place(bottom + center)[© Typst]  = Placement-#place(right, image("test/assets/files/tiger.jpg", width: 1.8cm))+#place(right, image("/assets/files/tiger.jpg", width: 1.8cm)) Hi there. This is \ a placed element. \ Unfortunately, \
test/typ/layout/transform-01.typ view
@@ -1,6 +1,6 @@ // Test combination of scaling and rotation. #set page(height: 80pt) #align(center + horizon,-  rotate(20deg, scale(70%, image("test/assets/files/tiger.jpg")))+  rotate(20deg, scale(70%, image("/assets/files/tiger.jpg"))) ) 
test/typ/layout/transform-02.typ view
@@ -1,5 +1,5 @@ // Test setting rotation origin. #rotate(10deg, origin: top + left,-  image("test/assets/files/tiger.jpg", width: 50%)+  image("/assets/files/tiger.jpg", width: 50%) ) 
test/typ/math/content-00.typ view
@@ -1,4 +1,4 @@ // Test images and font fallback.-#let monkey = move(dy: 0.2em, image("test/assets/files/monkey.svg", height: 1em))+#let monkey = move(dy: 0.2em, image("/assets/files/monkey.svg", height: 1em)) $ sum_(i=#emoji.apple)^#emoji.apple.red i + monkey/2 $ 
test/typ/meta/figure-00.typ view
@@ -10,7 +10,7 @@ ) <tab-basic>  #figure(-  pad(y: -6pt, image("test/assets/files/cylinder.svg", height: 2cm)),+  pad(y: -6pt, image("/assets/files/cylinder.svg", height: 2cm)),   caption: [The basic shapes.],   numbering: "I", ) <fig-cylinder>
test/typ/meta/figure-01.typ view
@@ -4,7 +4,7 @@   table(     columns: 2,     [Second cylinder],-    image("test/assets/files/cylinder.svg"),+    image("/assets/files/cylinder.svg"),   ),   caption: "A table containing images." ) <fig-image-in-table>
test/typ/meta/footnote-container-00.typ view
@@ -1,7 +1,7 @@ // Test footnote in caption. Read the docs #footnote[https://typst.app/docs]! #figure(-  image("test/assets/files/graph.png", width: 70%),+  image("/assets/files/graph.png", width: 70%),   caption: [     A graph #footnote[A _graph_ is a structure with nodes and edges.]   ]
@@ -1,6 +1,6 @@ // Link containing a block. #link("https://example.com/", block[   My cool rhino-  #box(move(dx: 10pt, image("test/assets/files/rhino.png", width: 1cm)))+  #box(move(dx: 10pt, image("/assets/files/rhino.png", width: 1cm))) ]) 
test/typ/meta/query-figure-00.typ view
@@ -21,7 +21,7 @@ })  #figure(-  image("test/assets/files/glacier.jpg"),+  image("/assets/files/glacier.jpg"),   caption: [Glacier melting], ) @@ -33,6 +33,6 @@ )  #figure(-  image("test/assets/files/tiger.jpg"),+  image("/assets/files/tiger.jpg"),   caption: [Tiger world], )
test/typ/meta/ref-03.typ view
@@ -14,13 +14,13 @@ }  #figure(-  image("test/assets/files/cylinder.svg", height: 3cm),+  image("/assets/files/cylinder.svg", height: 3cm),   caption: [A sylinder.],   supplement: "Fig", ) <fig1>  #figure(-  image("test/assets/files/tiger.jpg", height: 3cm),+  image("/assets/files/tiger.jpg", height: 3cm),   caption: [A tiger.],   supplement: "Figg", ) <fig2>
+ test/typ/regression/addons/example.typ view
@@ -0,0 +1,1 @@+#let utf8string = read("../something.txt")
+ test/typ/regression/issue59.typ view
@@ -0,0 +1,1 @@+#if 5 != <foo> {[a]}
+ test/typ/regression/issue60.typ view
@@ -0,0 +1,2 @@+#import "addons/example.typ": utf8string+#utf8string
+ test/typ/regression/something.txt view
@@ -0,0 +1,1 @@+Anything!
test/typ/text/baseline-00.typ view
@@ -9,4 +9,4 @@ that ever learned to mimic a human voice.
 
 ---
-Hey #box(baseline: 40%, image("test/assets/files/tiger.jpg", width: 1.5cm)) there!
+Hey #box(baseline: 40%, image("/assets/files/tiger.jpg", width: 1.5cm)) there!
test/typ/visualize/image-00.typ view
@@ -1,9 +1,9 @@ // Test loading different image formats.  // Load an RGBA PNG image.-#image("test/assets/files/rhino.png")+#image("/assets/files/rhino.png")  // Load an RGB JPEG image. #set page(height: 60pt)-#image("test/assets/files/tiger.jpg")+#image("/assets/files/tiger.jpg") 
test/typ/visualize/image-01.typ view
@@ -1,12 +1,12 @@ // Test configuring the size and fitting behaviour of images.  // Set width and height explicitly.-#box(image("test/assets/files/rhino.png", width: 30pt))-#box(image("test/assets/files/rhino.png", height: 30pt))+#box(image("/assets/files/rhino.png", width: 30pt))+#box(image("/assets/files/rhino.png", height: 30pt))  // Set width and height explicitly and force stretching.-#image("test/assets/files/monkey.svg", width: 100%, height: 20pt, fit: "stretch")+#image("/assets/files/monkey.svg", width: 100%, height: 20pt, fit: "stretch")  // Make sure the bounding-box of the image is correct.-#align(bottom + right, image("test/assets/files/tiger.jpg", width: 40pt, alt: "A tiger"))+#align(bottom + right, image("/assets/files/tiger.jpg", width: 40pt, alt: "A tiger")) 
test/typ/visualize/image-02.typ view
@@ -4,8 +4,8 @@   columns: (1fr, 1fr, 1fr),   rows: 100%,   gutter: 3pt,-  image("test/assets/files/tiger.jpg", width: 100%, height: 100%, fit: "contain"),-  image("test/assets/files/tiger.jpg", width: 100%, height: 100%, fit: "cover"),-  image("test/assets/files/monkey.svg", width: 100%, height: 100%, fit: "stretch"),+  image("/assets/files/tiger.jpg", width: 100%, height: 100%, fit: "contain"),+  image("/assets/files/tiger.jpg", width: 100%, height: 100%, fit: "cover"),+  image("/assets/files/monkey.svg", width: 100%, height: 100%, fit: "stretch"), ) 
test/typ/visualize/image-03.typ view
@@ -1,5 +1,5 @@ // Does not fit to remaining height of page. #set page(height: 60pt) Stuff-#image("test/assets/files/rhino.png")+#image("/assets/files/rhino.png") 
test/typ/visualize/image-04.typ view
@@ -1,3 +1,3 @@ // Test baseline.-A #box(image("test/assets/files/tiger.jpg", height: 1cm, width: 80%)) B+A #box(image("/assets/files/tiger.jpg", height: 1cm, width: 80%)) B 
test/typ/visualize/image-05.typ view
@@ -1,3 +1,3 @@ // Test advanced SVG features.-#image("test/assets/files/pattern.svg")+#image("/assets/files/pattern.svg") 
test/typ/visualize/image-08.typ view
@@ -1,2 +1,2 @@ // Error: 8-18 failed to parse svg: found closing tag 'g' instead of 'style' in line 4-#image("test/assets/files/bad.svg")+#image("/assets/files/bad.svg")
test/typ/visualize/svg-text-00.typ view
@@ -1,6 +1,6 @@ #set page(width: 250pt)  #figure(-  image("test/assets/files/diagram.svg"),+  image("/assets/files/diagram.svg"),   caption: [A textful diagram], )
typst.cabal view
@@ -1,6 +1,6 @@ cabal-version:      2.4 name:               typst-version:            0.6.1+version:            0.6.2 synopsis:           Parsing and evaluating typst syntax. description:        A library for parsing and evaluating typst syntax.                     Typst (<https://typst.app>) is a document layout and@@ -16,6 +16,8 @@ extra-doc-files:    CHANGELOG.md extra-source-files: test/typ/**/*.typ                     test/out/**/*.out+                    test/typ/regression/something.txt+                    test/typ/regression/addons/example.typ                     test/assets/files/*.png                     test/assets/files/*.jpg                     test/assets/files/*.bib@@ -50,6 +52,7 @@                       Typst.Bind                       Typst.Regex                       Typst.Show+                      Typst.Constructors                       Typst.Module.Standard                       Typst.Module.Math                       Typst.Module.Calc