From 82617a6a3cb4d1d7b8b4ed52f2adb31a3a148114 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sat, 9 Mar 2024 12:55:03 +0100 Subject: Generate PDF ID automatically unless we really have a stable ID (#3591) --- crates/typst-cli/src/compile.rs | 13 ++++--------- crates/typst-cli/src/world.rs | 8 -------- 2 files changed, 4 insertions(+), 17 deletions(-) (limited to 'crates/typst-cli') diff --git a/crates/typst-cli/src/compile.rs b/crates/typst-cli/src/compile.rs index 8e628b4e..9a252a53 100644 --- a/crates/typst-cli/src/compile.rs +++ b/crates/typst-cli/src/compile.rs @@ -9,7 +9,7 @@ use parking_lot::RwLock; use rayon::iter::{IndexedParallelIterator, IntoParallelRefIterator, ParallelIterator}; use typst::diag::{bail, At, Severity, SourceDiagnostic, StrResult}; use typst::eval::Tracer; -use typst::foundations::Datetime; +use typst::foundations::{Datetime, Smart}; use typst::layout::Frame; use typst::model::Document; use typst::syntax::{FileId, Source, Span}; @@ -157,18 +157,13 @@ fn export( OutputFormat::Svg => { export_image(world, document, command, watching, ImageExportFormat::Svg) } - OutputFormat::Pdf => export_pdf(document, command, world), + OutputFormat::Pdf => export_pdf(document, command), } } /// Export to a PDF. -fn export_pdf( - document: &Document, - command: &CompileCommand, - world: &SystemWorld, -) -> StrResult<()> { - let ident = world.input().map(|i| i.to_string_lossy()); - let buffer = typst_pdf::pdf(document, ident.as_deref(), now()); +fn export_pdf(document: &Document, command: &CompileCommand) -> StrResult<()> { + let buffer = typst_pdf::pdf(document, Smart::Auto, now()); let output = command.output(); fs::write(output, buffer) .map_err(|err| eco_format!("failed to write PDF file ({err})"))?; diff --git a/crates/typst-cli/src/world.rs b/crates/typst-cli/src/world.rs index 893b02bd..4e0bcd54 100644 --- a/crates/typst-cli/src/world.rs +++ b/crates/typst-cli/src/world.rs @@ -29,8 +29,6 @@ static STDIN_ID: Lazy = pub struct SystemWorld { /// The working directory. workdir: Option, - /// The canonical path to the input file. - input: Option, /// The root relative to which absolute paths are resolved. root: PathBuf, /// The input path. @@ -108,7 +106,6 @@ impl SystemWorld { Ok(Self { workdir: std::env::current_dir().ok(), - input, root, main, library: Prehashed::new(library), @@ -152,11 +149,6 @@ impl SystemWorld { self.now.take(); } - /// Return the canonical path to the input file. - pub fn input(&self) -> Option<&PathBuf> { - self.input.as_ref() - } - /// Lookup a source file by id. #[track_caller] pub fn lookup(&self, id: FileId) -> Source { -- cgit v1.2.3