summaryrefslogtreecommitdiff
path: root/crates/typst-cli/src
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2024-03-09 12:55:03 +0100
committerGitHub <noreply@github.com>2024-03-09 11:55:03 +0000
commit82617a6a3cb4d1d7b8b4ed52f2adb31a3a148114 (patch)
treed9242fac2c8c17ad3feaedae41c19d91ecabe902 /crates/typst-cli/src
parent204c4ecfcb5b0dfc4d34e5622af603c2c190af69 (diff)
Generate PDF ID automatically unless we really have a stable ID (#3591)
Diffstat (limited to 'crates/typst-cli/src')
-rw-r--r--crates/typst-cli/src/compile.rs13
-rw-r--r--crates/typst-cli/src/world.rs8
2 files changed, 4 insertions, 17 deletions
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<FileId> =
pub struct SystemWorld {
/// The working directory.
workdir: Option<PathBuf>,
- /// The canonical path to the input file.
- input: Option<PathBuf>,
/// 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 {