Skip to content

Commit 2083b1d

Browse files
authored
Bugfix/issue 3762 (#3924)
* add format variants to output recipe name * changelog * fix default filenames correctly
1 parent f95618c commit 2083b1d

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

news/changelog-1.3.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
- Previously, if the `pdf-engine` was set to `latexmk`, we would bypass many features of Quarto and use Pandoc to produce the PDF output. Starting in in Quarto 1.3, all Quarto features will be enabled for the `latexmk` engine and `latexmk` will be used to run the PDF generation loop.
3838
- Fix author processing in default PDFs for complex author names (#3483)
3939
- Remove excessive vertical space between theorem type blocks ([#3776](https://github.com/quarto-dev/quarto-cli/issues/3776)).
40+
- Fix temporary `.tex` filenames in the presence of multiple variants ([#3762](https://github.com/quarto-dev/quarto-cli/issues/3762)).
41+
- Note that this fix changes the filenames used for PDF files with variants. In quarto 1.3, the automatic output names for PDF files include format variants and modifiers.
4042

4143
## Beamer Format
4244

src/command/render/output-tex.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { kStdOut, replacePandocOutputArg } from "./flags.ts";
2020
import { OutputRecipe } from "./types.ts";
2121
import { pdfEngine } from "../../config/pdf.ts";
2222
import { execProcess } from "../../core/process.ts";
23+
import { parseFormatString } from "../../core/pandoc/pandoc-formats.ts";
2324

2425
export interface PdfGenerator {
2526
generate: (
@@ -44,7 +45,18 @@ export function texToPdfOutputRecipe(
4445

4546
// there are many characters that give tex trouble in filenames, create
4647
// a target stem that replaces them with the '-' character
47-
const texStem = texSafeFilename(inputStem);
48+
49+
// include variants in the tex stem if they are present to avoid
50+
// overwriting files
51+
let fixupInputName = "";
52+
if (format.identifier["target-format"]) {
53+
const formatDesc = parseFormatString(format.identifier["target-format"]);
54+
fixupInputName = `${formatDesc.variants.join("")}${
55+
formatDesc.modifiers.join("")
56+
}`;
57+
}
58+
59+
const texStem = texSafeFilename(`${inputStem}${fixupInputName}`);
4860

4961
// cacluate output and args for pandoc (this is an intermediate file
5062
// which we will then compile to a pdf and rename to .tex)

tests/smoke/render/render-format-extension.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ testRender(
7272
// deno-lint-ignore require-await
7373
teardown: async () => {
7474
// Clean up the SPL file that is generated by the elesevier class
75-
Deno.removeSync(docs("extensions/format/academic/document.spl"));
75+
Deno.removeSync(docs("extensions/format/academic/document+foobar.spl"));
7676
},
7777
},
7878
);

tests/utils.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,15 @@ import { parseFormatString } from "../src/core/pandoc/pandoc-formats.ts";
1212
export function outputForInput(input: string, to: string) {
1313
// TODO: Consider improving this (e.g. for cases like Beamer)
1414
const dir = dirname(input);
15-
const stem = basename(input, extname(input));
15+
let stem = basename(input, extname(input));
1616

1717
const formatDesc = parseFormatString(to);
1818
const baseFormat = formatDesc.baseFormat;
19+
if (formatDesc.baseFormat === "pdf") {
20+
stem = `${stem}${formatDesc.variants.join("")}${
21+
formatDesc.modifiers.join("")
22+
}`;
23+
}
1924

2025
let outputExt = baseFormat || "html";
2126
if (baseFormat === "latex" || baseFormat == "context") {

0 commit comments

Comments
 (0)