diff options
| author | Laurenz <laurmaedje@gmail.com> | 2024-01-17 21:50:35 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2024-01-17 21:53:20 +0100 |
| commit | 6ac71eeaf7b68dab07f75bd1a480810481fa9b73 (patch) | |
| tree | d452e7323200fe56d61a34b91c8b98826d60978c /crates/typst-cli | |
| parent | 50741209a8f4c5e91d35281eb44b7425b3d022b2 (diff) | |
Add `Page` struct
To get rid of the Meta hack where numbering and things like that are stored in the frame.
Diffstat (limited to 'crates/typst-cli')
| -rw-r--r-- | crates/typst-cli/src/compile.rs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/crates/typst-cli/src/compile.rs b/crates/typst-cli/src/compile.rs index ea612630..2c80ce3f 100644 --- a/crates/typst-cli/src/compile.rs +++ b/crates/typst-cli/src/compile.rs @@ -219,7 +219,7 @@ fn export_image( .pages .par_iter() .enumerate() - .map(|(i, frame)| { + .map(|(i, page)| { let storage; let path = if numbered { storage = string.replace("{n}", &format!("{:0width$}", i + 1)); @@ -231,20 +231,23 @@ fn export_image( // If we are not watching, don't use the cache. // If the frame is in the cache, skip it. // If the file does not exist, always create it. - if watching && cache.is_cached(i, frame) && path.exists() { + if watching && cache.is_cached(i, &page.frame) && path.exists() { return Ok(()); } match fmt { ImageExportFormat::Png => { - let pixmap = - typst_render::render(frame, command.ppi / 72.0, Color::WHITE); + let pixmap = typst_render::render( + &page.frame, + command.ppi / 72.0, + Color::WHITE, + ); pixmap .save_png(path) .map_err(|err| eco_format!("failed to write PNG file ({err})"))?; } ImageExportFormat::Svg => { - let svg = typst_svg::svg(frame); + let svg = typst_svg::svg(&page.frame); fs::write(path, svg.as_bytes()) .map_err(|err| eco_format!("failed to write SVG file ({err})"))?; } |
