diff --git a/crates/typst-cli/src/compile.rs b/crates/typst-cli/src/compile.rs index c2d6ea01b..49a6b6eb3 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.