Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/changelog-1.6.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ All changes included in 1.6:
- Upgrade `mermaidjs` to 11.2.0.
- Upgrade Pandoc to 3.4.
- Upgrade `deno` to 1.46.3.
- ([#11068](https://github.com/quarto-dev/quarto-cli/issues/11068)): use standard location when writing to standard output to avoid breakage under `self-contained: true`.
- ([#10162](https://github.com/quarto-dev/quarto-cli/issues/10162)): Use Edge on `macOS` as a Chromium browser when available.
- ([#10235](https://github.com/quarto-dev/quarto-cli/issues/10235)): Configure the CI schedule trigger to activate exclusively for the upstream repository.
- ([#10295](https://github.com/quarto-dev/quarto-cli/issues/10235)): Fix regression to return error status to shell when `CommandError` is thrown.
Expand Down
15 changes: 8 additions & 7 deletions src/command/render/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export function outputRecipe(
});
}

if (!recipe.output) {
const deriveAutoOutput = () => {
// no output specified: derive an output path from the extension

// derive new output file
Expand All @@ -200,15 +200,16 @@ export function outputRecipe(

// assign output
updateOutput(output);
};

if (!recipe.output) {
deriveAutoOutput();
} else if (recipe.output === kStdOut) {
// output to stdout: direct pandoc to write to a temp file then we'll
// forward to stdout (necessary b/c a postprocesor may need to act on
// the output before its complete)
updateOutput(options.services.temp.createFile({ suffix: "." + ext }));
deriveAutoOutput();
recipe.isOutputTransient = true;
completeActions.push(() => {
writeFileToStdout(recipe.output);
Deno.removeSync(recipe.output);
writeFileToStdout(join(inputDir, recipe.output));
Deno.removeSync(join(inputDir, recipe.output));
});
} else if (!isAbsolute(recipe.output)) {
// relatve output file on the command line: make it relative to the input dir
Expand Down
25 changes: 19 additions & 6 deletions src/command/render/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,25 +276,38 @@ export async function renderPandoc(
await withTimingAsync("postprocess-selfcontained", async () => {
// ensure flags
const flags = context.options.flags || {};

// call complete handler (might e.g. run latexmk to complete the render)
finalOutput = await recipe.complete(pandocOptions) || recipe.output;

// determine whether this is self-contained output
finalOutput = recipe.output;

// note that we intentionally call isSelfContainedOutput twice
// the first needs to happen before recipe completion
// because ingestion of self-contained output needs
// to happen before recipe completion (which cleans up some files)
selfContained = isSelfContainedOutput(
flags,
format,
finalOutput,
);

// If this is self-contained, run pandoc to 'suck in' the dependencies
// which may have been added in the post processor
if (selfContained && isHtmlFileOutput(format.pandoc)) {
await pandocIngestSelfContainedContent(
outputFile,
format.pandoc[kResourcePath],
);
}

// call complete handler (might e.g. run latexmk to complete the render)
finalOutput = (await recipe.complete(pandocOptions)) || recipe.output;

// note that we intentionally call isSelfContainedOutput twice
// the second call happens because some recipes change
// their output extension on completion (notably, .pdf files)
// and become self-contained for purposes of cleanup
selfContained = isSelfContainedOutput(
flags,
format,
finalOutput,
);
});

// compute the relative path to the files dir
Expand Down
7 changes: 7 additions & 0 deletions tests/docs/self-contained/simple.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
format:
html:
self-contained: true
---

## Hello
14 changes: 14 additions & 0 deletions tests/smoke/self-contained/stdout.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { quarto } from "../../../src/quarto.ts";
import { test } from "../../test.ts";

test({
name: "https://github.com/quarto-dev/quarto-cli/issues/11068",
context: {
setup: async() => {
await quarto(["render", "docs/self-contained/simple.qmd", "-o", "-"]);
}
},
execute: async () => {},
verify: [],
type: "smoke"
});
Loading