Skip to content

Commit e2fbed9

Browse files
authored
Image in mediabag needs to be written in binary mode (#3995)
fixes #3982
1 parent cc21e35 commit e2fbed9

File tree

5 files changed

+51
-7
lines changed

5 files changed

+51
-7
lines changed

.github/workflows/test-smokes.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ jobs:
8888

8989
- name: Smoke Test Commits
9090
if: github.event.before != ''
91+
env:
92+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9193
run: |
9294
git checkout ${{ github.sha}}
9395
pushd tests

news/changelog-1.3.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
- Remove excessive vertical space between theorem type blocks ([#3776](https://github.com/quarto-dev/quarto-cli/issues/3776)).
4343
- Fix temporary `.tex` filenames in the presence of multiple variants ([#3762](https://github.com/quarto-dev/quarto-cli/issues/3762)).
4444
- 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.
45+
- Correctly download online image on Windows ([#3982](https://github.com/quarto-dev/quarto-cli/issues/3982)).
4546

4647
## Beamer Format
4748

src/resources/pandoc/datadir/init.lua

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1744,10 +1744,12 @@ local function file_exists(name)
17441744
return false
17451745
end
17461746
end
1747-
1748-
local function write_file(path, contents)
1747+
1748+
1749+
local function write_file(path, contents, mode)
17491750
pandoc.system.make_directory(pandoc.path.directory(path), true)
1750-
local file = io.open(path, "a")
1751+
mode = mode or "a"
1752+
local file = io.open(path, mode)
17511753
if file then
17521754
file:write(contents)
17531755
file:close()
@@ -1789,7 +1791,12 @@ _quarto = {
17891791
projectOffset = projectOffset,
17901792
file = {
17911793
read = read_file,
1792-
write = write_file,
1794+
write = function(path, contents)
1795+
return write_file(path, contents, "wb")
1796+
end,
1797+
write_text = function(path, contents)
1798+
return write_file(path, contents, "a")
1799+
end,
17931800
exists = file_exists,
17941801
remove = remove_file
17951802
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: "Penguins, meet Quarto!"
3+
format: pdf
4+
keep-tex: true
5+
_quarto:
6+
tests:
7+
pdf:
8+
noErrors: default
9+
fileExists:
10+
supportPath: mediabag/lter_penguins.png
11+
---
12+
13+
## Meet the penguins
14+
15+
![](https://raw.githubusercontent.com/quarto-dev/quarto-web/main/docs/get-started/hello/rstudio/lter_penguins.png){style="float:right;" fig-alt="Illustration of three species of Palmer Archipelago penguins: Chinstrap, Gentoo, and Adelie. Artwork by @allison_horst." width="401"}
16+
17+

tests/smoke/smoke-all.test.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import { expandGlobSync } from "../../src/core/deno/expand-glob.ts";
99
import { testQuartoCmd, Verify } from "../test.ts";
10-
1110
import { initYamlIntelligenceResourcesFromFilesystem } from "../../src/core/schema/utils.ts";
1211
import {
1312
initState,
@@ -21,13 +20,15 @@ import {
2120
ensureDocxRegexMatches,
2221
ensureFileRegexMatches,
2322
ensureHtmlElements,
23+
fileExists,
2424
noErrors,
2525
noErrorsOrWarnings,
2626
} from "../verify.ts";
2727
import { readYamlFromMarkdown } from "../../src/core/yaml.ts";
2828
import { outputForInput } from "../utils.ts";
2929
import { jupyterToMarkdown } from "../../src/core/jupyter/jupyter.ts";
3030
import { jupyterNotebookToMarkdown } from "../../src/command/convert/jupyter.ts";
31+
import { dirname, join } from "path/mod.ts";
3132

3233
async function fullInit() {
3334
await initYamlIntelligenceResourcesFromFilesystem();
@@ -99,8 +100,24 @@ function resolveTestSpecs(
99100
checkWarnings = false;
100101
verifyFns.push(noErrors);
101102
} else {
102-
if (verifyMap[key]) {
103-
const outputFile = outputForInput(input, format);
103+
const outputFile = outputForInput(input, format);
104+
if (key === "fileExists") {
105+
for (
106+
const [path, file] of Object.entries(
107+
value as Record<string, string>,
108+
)
109+
) {
110+
if (path === "outputPath") {
111+
verifyFns.push(
112+
fileExists(join(dirname(outputFile.outputPath), file)),
113+
);
114+
} else if (path === "supportPath") {
115+
verifyFns.push(
116+
fileExists(join(outputFile.supportPath, file)),
117+
);
118+
}
119+
}
120+
} else if (verifyMap[key]) {
104121
verifyFns.push(verifyMap[key](outputFile.outputPath, ...value));
105122
}
106123
}

0 commit comments

Comments
 (0)