summaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorLU Jialin <luxxxlucy@gmail.com>2023-09-18 20:27:38 +0800
committerGitHub <noreply@github.com>2023-09-18 14:27:38 +0200
commit8b465222b2bf263a03faae7b0ad62f326c758244 (patch)
treed6ee2ae50dd93ef5a8a0850dd66950bfbe25e87f /crates
parent6378bb17547aeb3c24462c2127df01033a05dd53 (diff)
Use inferred format extension for the output path (#2166)
Diffstat (limited to 'crates')
-rw-r--r--crates/typst-cli/src/compile.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/crates/typst-cli/src/compile.rs b/crates/typst-cli/src/compile.rs
index c2d6ea01..49a6b6eb 100644
--- a/crates/typst-cli/src/compile.rs
+++ b/crates/typst-cli/src/compile.rs
@@ -22,9 +22,15 @@ type CodespanError = codespan_reporting::files::Error;
impl CompileCommand {
/// The output path.
pub fn output(&self) -> PathBuf {
- self.output
- .clone()
- .unwrap_or_else(|| self.common.input.with_extension("pdf"))
+ self.output.clone().unwrap_or_else(|| {
+ self.common.input.with_extension(
+ match self.output_format().unwrap_or(OutputFormat::Pdf) {
+ OutputFormat::Pdf => "pdf",
+ OutputFormat::Png => "png",
+ OutputFormat::Svg => "svg",
+ },
+ )
+ })
}
/// The format to use for generated output, either specified by the user or inferred from the extension.