Skip to content

Commit a87de21

Browse files
Fix Windows CI, update README, bump to 0.1.3
- Escape backslashes in test TOML paths for Windows compatibility (\U in Windows temp paths was parsed as TOML unicode escape) - Document both @Preview and @Local workflows with equal footing - Add env var and CLI flag usage examples for typst compile - Add directory layout diagram showing cache structure - Add repository URL to Cargo.toml
1 parent 360dfe5 commit a87de21

File tree

4 files changed

+43
-16
lines changed

4 files changed

+43
-16
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
[package]
22
name = "typst-gather"
3-
version = "0.1.2"
3+
version = "0.1.3"
44
edition = "2021"
5+
repository = "https://github.com/quarto-dev/typst-gather"
56
rust-version = "1.81"
67

78
[dependencies]

README.md

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,22 @@ cargo install --path .
1414
typst-gather packages.toml
1515
```
1616

17-
Then set `TYPST_PACKAGE_CACHE_PATH` to the destination directory when running Typst.
17+
Then point both `TYPST_PACKAGE_CACHE_PATH` and `TYPST_PACKAGE_PATH` at the
18+
destination directory so Typst can resolve both `@preview` and `@local` packages:
19+
20+
```bash
21+
export TYPST_PACKAGE_CACHE_PATH=/path/to/packages
22+
export TYPST_PACKAGE_PATH=/path/to/packages
23+
typst compile document.typ
24+
```
25+
26+
Or equivalently, using CLI flags:
27+
28+
```bash
29+
typst compile document.typ \
30+
--package-cache-path /path/to/packages \
31+
--package-path /path/to/packages
32+
```
1833

1934
## TOML format
2035

@@ -35,21 +50,32 @@ fontawesome = "0.5.0"
3550
my-template = "/path/to/src"
3651
```
3752

38-
- `destination` - Required. Directory where packages will be gathered.
39-
- `discover` - Optional. Paths to scan for imports. Can be:
53+
- `destination` Required. Directory where packages will be gathered.
54+
- `discover` Optional. Paths to scan for `#import` statements. Can be:
4055
- A single string path
4156
- An array of paths
4257
- Each path can be a `.typ` file or a directory (scans `.typ` files non-recursively)
43-
- `[preview]` packages are downloaded from Typst Universe (cached - skipped if already present)
44-
- `[local]` packages are copied from the specified directory (always fresh - version read from `typst.toml`)
58+
- `[preview]` — Packages downloaded from Typst Universe. Skipped if already cached.
59+
- `[local]` — Packages copied from a local directory. The source must contain a
60+
`typst.toml` manifest with `name` and `version` fields. Always copies fresh
61+
(overwrites any existing version).
62+
63+
## How it works
64+
65+
Both `@preview` and `@local` packages are written to the `destination` directory
66+
using Typst's standard cache layout:
4567

46-
## Features
68+
```
69+
destination/
70+
├── preview/
71+
│ ├── cetz/0.4.1/
72+
│ └── fontawesome/0.5.0/
73+
└── local/
74+
└── my-template/1.0.0/
75+
```
4776

48-
- Recursively resolves `@preview` dependencies from `#import` statements
49-
- Uses Typst's own parser for reliable import detection
50-
- Discover mode scans .typ files for imports
51-
- Local packages always overwrite (clean slate)
52-
- Preview packages skip if already cached
77+
Recursively resolves `@preview` dependencies from `#import` statements using
78+
Typst's own parser for reliable import detection.
5379

5480
## Quarto Integration
5581

tests/integration.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,8 @@ destination = "{}"
324324
[local]
325325
my-pkg = "{}"
326326
"#,
327-
cache_dir.path().display(),
328-
src_dir.path().display()
327+
cache_dir.path().display().to_string().replace('\\', "/"),
328+
src_dir.path().display().to_string().replace('\\', "/")
329329
);
330330

331331
let config = Config::parse(&toml).unwrap();
@@ -342,7 +342,7 @@ my-pkg = "{}"
342342
fn empty_config_does_nothing() {
343343
let cache_dir = TempDir::new().unwrap();
344344

345-
let toml = format!(r#"destination = "{}""#, cache_dir.path().display());
345+
let toml = format!(r#"destination = "{}""#, cache_dir.path().display().to_string().replace('\\', "/"));
346346
let config = Config::parse(&toml).unwrap();
347347
let dest = config.destination.clone().unwrap();
348348
let configured_local: HashSet<String> = config.local.keys().cloned().collect();

0 commit comments

Comments
 (0)