Skip to content

Commit cf48867

Browse files
authored
Merge pull request #1342 from quarto-dev/bugfix/github-issue-1340
Fix disappearing supporting images bug (#1340)
2 parents 0e6a1a0 + d925d01 commit cf48867

File tree

5 files changed

+76
-2
lines changed

5 files changed

+76
-2
lines changed

src/command/render/project.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,12 @@ export async function renderProject(
294294
renderedFile.supporting = renderedFile.supporting.filter((file) =>
295295
file !== libDir
296296
);
297+
// ensure that we don't have overlapping paths in supporting
298+
renderedFile.supporting = renderedFile.supporting.filter((file) => {
299+
return !renderedFile.supporting!.some((dir) =>
300+
file.startsWith(dir) && file !== dir
301+
);
302+
});
297303
if (keepFiles) {
298304
renderedFile.supporting.map((file) => copyDir(file));
299305
} else {

src/core/handlers/mermaid.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ mermaid.initialize();
203203
const m = defEl.innerHTML.match(/id="([^\"]+)"/);
204204
if (m) {
205205
const id = m[1];
206-
console.log("Will try to patch", id);
207206
idsToPatch.push(id);
208207
}
209208
}
@@ -328,7 +327,6 @@ mermaid.initialize();
328327

329328
const attrs: Record<string, unknown> = {};
330329
if (isRevealjsOutput(handlerContext.options.context.format.pandoc)) {
331-
console.log("Setting reveal to true");
332330
attrs.reveal = true;
333331
}
334332

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
project:
2+
type: book
3+
4+
book:
5+
title: "btest"
6+
author: "Jane Doe"
7+
date: "7/7/2022"
8+
chapters:
9+
- index.qmd
10+
11+
format:
12+
html:
13+
theme: cosmo
14+
15+
16+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Descriptive Statistics, Distributions, and Graphics {#sec-descript}
2+
3+
```{mermaid}
4+
flowchart TD
5+
mpy[Mean or Proportion<br>of Y vs. X] --> nps[Nonparametric<br>Smoother]
6+
```
7+
```{r}
8+
x <- seq(-3, 35, length=150)
9+
xl <- expression(x)
10+
plot(x, dt(x, 4, 6), type='l', xlab=xl, ylab='')
11+
```
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* github-issue-1340.test.ts
3+
*
4+
* Copyright (C) 2022 by RStudio, PBC
5+
*
6+
*/
7+
8+
import { docs, fileLoader, outputForInput } from "../../utils.ts";
9+
import {
10+
ensureHtmlElements,
11+
ensureHtmlSelectorSatisfies,
12+
verifyPath,
13+
} from "../../verify.ts";
14+
import { testRender } from "../../smoke/render/render.ts";
15+
import { ExecuteOutput } from "../../test.ts";
16+
import { join } from "path/mod.ts";
17+
18+
const input = docs("bug-repros/issue-1340/");
19+
const output = join(input, "_book");
20+
// const output = outputForInput(join(input, "index.qmd"), "html"); <- doesn't work for book projects, right.
21+
testRender(input, "html", false, [{
22+
name: "file exists",
23+
verify: (_outputs: ExecuteOutput[]): Promise<void> => {
24+
verifyPath(
25+
join(
26+
output,
27+
"index_files",
28+
"figure-html",
29+
"unnamed-chunk-4-1.png",
30+
),
31+
);
32+
return Promise.resolve();
33+
},
34+
}, {
35+
name: "manual cleanup for book project",
36+
verify: (_outputs: ExecuteOutput[]): Promise<void> => {
37+
Deno.removeSync(output, { recursive: true });
38+
Deno.removeSync(join(input, ".quarto"), { recursive: true });
39+
Deno.removeSync(join(input, ".gitignore"));
40+
41+
return Promise.resolve();
42+
},
43+
}]);

0 commit comments

Comments
 (0)