Skip to content

Commit 8f47a46

Browse files
author
Al Manning
committed
Merge branch 'main' into task/warn-perms
2 parents f0880e7 + 19ecc6f commit 8f47a46

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+478
-182
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,4 @@ body:
3939
- label: "Please [format your issue](https://quarto.org/bug-reports.html#formatting-make-githubs-markdown-work-for-us) so it is easier for us to read the bug report."
4040
- label: Please document the RStudio IDE version you're running (if applicable), by providing the value displayed in the "About RStudio" main menu dialog?
4141
- label: Please document the operating system you're running. If on Linux, please provide the specific distribution.
42+
- label: Please provide the output of `quarto check` so we know which version of quarto and its dependencies you're running.

news/changelog-1.3.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@
150150
- Improve title recognition for pages that don't include a title in metadata ([#4528](https://github.com/quarto-dev/quarto-cli/issues/4528))
151151
- Ensure that footnote are properly indexed for website and book searches ([#4601](https://github.com/quarto-dev/quarto-cli/issues/4601)).
152152
- Permit sidebar items to include icons ([#3830](https://github.com/quarto-dev/quarto-cli/issues/3830)).
153+
- Use light navbar background by default for generated websites.
153154

154155
## Books
155156

@@ -207,6 +208,7 @@
207208
- Fix issue with "No inspectable targets" with Chrome Browser ([#4653](https://github.com/quarto-dev/quarto-cli/issues/4653))
208209
- Add `title` attribute for callouts (can be used rather than heading for defining the title)
209210
- Handle more varieties of raw HTML for Docusaurus output
211+
- Read and process DOM one-file-at-time in books and websites to reduce total memory usage ([#4350](https://github.com/quarto-dev/quarto-cli/issues/4350)).
210212

211213
## Pandoc filter changes
212214

src/command/render/codetools.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,24 @@ export function codeToolsPostprocessor(format: Format) {
140140
const codeTools = resolveCodeTools(format, doc);
141141
if (codeTools.source || codeTools.toggle) {
142142
const title = doc.querySelector("#title-block-header h1");
143-
if (title) {
144-
const header = (title as Element).parentElement;
143+
const header = title !== null
144+
? (title as Element).parentElement
145+
: doc.querySelector("main.content");
146+
147+
if (header) {
145148
const titleDiv = doc.createElement("div");
146149
titleDiv.classList.add("quarto-title-block");
147150
const layoutDiv = doc.createElement("div");
148151
titleDiv.appendChild(layoutDiv);
149-
header?.replaceChild(titleDiv, title);
150-
layoutDiv.appendChild(title);
152+
if (title) {
153+
header?.replaceChild(titleDiv, title);
154+
layoutDiv.appendChild(title);
155+
} else {
156+
// create an empty title
157+
const h1El = doc.createElement("h1");
158+
layoutDiv.appendChild(h1El);
159+
layoutDiv.classList.add("quarto-title-tools-only");
160+
}
151161
const button = doc.createElement("button");
152162
button.setAttribute("type", "button");
153163
button.classList.add("btn");
@@ -159,7 +169,13 @@ export function codeToolsPostprocessor(format: Format) {
159169
button.appendChild(doc.createTextNode(" " + codeTools.caption));
160170
}
161171
layoutDiv.appendChild(button);
162-
header!.appendChild(titleDiv);
172+
173+
if (title) {
174+
header!.appendChild(titleDiv);
175+
} else {
176+
header!.prepend(titleDiv);
177+
}
178+
163179
if (codeTools.toggle) {
164180
button.setAttribute("id", kCodeToolsMenuButtonId);
165181
button.classList.add("dropdown-toggle");

src/command/render/pandoc.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -703,16 +703,11 @@ export async function runPandoc(
703703
// timing results json file
704704
const timingResultsFile = options.services.temp.createFile();
705705

706-
if (allDefaults.to?.match(/[.]lua$/)) {
707-
formatFilterParams["custom-writer"] = allDefaults.to;
708-
allDefaults.to = resourcePath("filters/customwriter/customwriter.lua");
709-
}
710-
if (Deno.env.get("QUARTO_ALLENMANNING_WORKAROUND_CONFLUENCE") === undefined) {
711-
if (allDefaults.writer?.match(/[.]lua$/)) {
712-
formatFilterParams["custom-writer"] = allDefaults.writer;
713-
allDefaults.writer = resourcePath(
714-
"filters/customwriter/customwriter.lua",
715-
);
706+
const writerKeys: ("to" | "writer")[] = ["to", "writer"];
707+
for (const key of writerKeys) {
708+
if (allDefaults[key]?.match(/[.]lua$/)) {
709+
formatFilterParams["custom-writer"] = allDefaults[key];
710+
allDefaults[key] = resourcePath("filters/customwriter/customwriter.lua");
716711
}
717712
}
718713

src/command/render/render-contexts.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,8 +656,12 @@ const readExtensionFormat = async (
656656
// Read the yaml file and resolve / bucketize
657657
const extensionFormat = extension?.contributes.formats;
658658
if (extensionFormat) {
659+
const fmtTarget = formatDesc.modifiers
660+
? `${formatDesc.baseFormat}${formatDesc.modifiers.join("")}`
661+
: formatDesc.baseFormat;
659662
const extensionMetadata =
660-
(extensionFormat[formatDesc.baseFormat] || {}) as Metadata;
663+
(extensionFormat[fmtTarget] || extensionFormat[formatDesc.baseFormat] ||
664+
{}) as Metadata;
661665
extensionMetadata[kExtensionName] = extensionMetadata[kExtensionName] ||
662666
formatDesc.extension;
663667

src/config/constants.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,13 @@ export const kCrossrefChaptersAppendix = "chapters-appendix";
513513
export const kCrossrefChaptersAlpha = "chapters-alpha";
514514
export const kCrossrefChapterId = "chapter-id";
515515

516+
export const kGrid = "grid";
517+
export const kContentMode = "content-mode";
518+
export const kAuto = "auto";
519+
export const kStandardContent = "standard";
520+
export const kFullContent = "full";
521+
export const kSlimContent = "slim";
522+
516523
export const kFigResponsive = "fig-responsive";
517524
export const kOutputLocation = "output-location";
518525

src/core/cri/cri.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,31 @@ export async function criClient(appPath?: string, port?: number) {
7676
}
7777
const app: string = appPath || await getBrowserExecutablePath();
7878

79+
const version = Deno.run({
80+
cmd: [app, "--version"],
81+
stdout: "piped",
82+
stderr: "piped",
83+
});
84+
const [status, stdout, _stderr] = await Promise.all([
85+
version.status(),
86+
version.output(),
87+
version.stderrOutput(),
88+
]);
89+
if (!status.success) {
90+
throw new Error(`Failed to get chrome version`);
91+
}
92+
const versionString = new TextDecoder().decode(stdout);
93+
let versionNumber = 0;
94+
95+
const chromeMatch = versionString.match(/Google Chrome (\d+)/);
96+
if (chromeMatch) {
97+
versionNumber = Number(chromeMatch[1]);
98+
}
99+
const chromiumMatch = versionString.match(/Chromium (\d+)/);
100+
if (chromiumMatch) {
101+
versionNumber = Number(chromiumMatch[1]);
102+
}
103+
79104
const cmd = [
80105
app,
81106
"--headless",
@@ -113,7 +138,7 @@ export async function criClient(appPath?: string, port?: number) {
113138
const maxTries = 5;
114139
for (let i = 0; i < maxTries; ++i) {
115140
try {
116-
client = await cdp({ port });
141+
client = await cdp({ port, version: versionNumber });
117142
break;
118143
} catch (e) {
119144
if (i === maxTries - 1) {

src/core/cri/deno-cri/devtools.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ export async function New(options) {
5050
if (Object.prototype.hasOwnProperty.call(options, "url")) {
5151
options.path += `?${options.url}`;
5252
}
53+
// we don't mutate here because we don't want other
54+
// calls to have PUT as the method
55+
if (options.version >= 109) {
56+
options = {
57+
...options,
58+
method: "PUT",
59+
};
60+
}
5361
const result = await devToolsInterface(options);
5462
return JSON.parse(result);
5563
}

src/core/cri/deno-cri/external-request.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ export default async function externalRequest(options) {
1818
}*/
1919

2020
const url = `${options.protocol}:/${options.host}:${options.port}${options.path}`;
21-
const response = await fetch(url);
21+
const fetchOpts = {};
22+
if (options.method) {
23+
fetchOpts.method = options.method;
24+
}
25+
const response = await fetch(url, options);
2226
const text = await response.text();
2327

2428
if (response.status !== 200) {

src/core/deno-dom.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,20 @@ export async function parseHtml(src: string): Promise<HTMLDocument> {
2525
return result;
2626
}
2727

28+
export async function writeDomToHtmlFile(
29+
doc: HTMLDocument,
30+
path: string,
31+
doctype?: string,
32+
) {
33+
if (doc.documentElement === null) {
34+
throw new Error("Document has no root element");
35+
}
36+
const output = doctype
37+
? doctype + "\n" + doc.documentElement.outerHTML
38+
: doc.documentElement.outerHTML;
39+
await Deno.writeTextFile(path, output);
40+
}
41+
2842
// We are combining a number of scripts from
2943
// https://github.com/b-fuze/deno-dom/blob/master/deno-dom-native.ts
3044
// into this. If deno-dom fails, it's likely that this needs to be brought up to date.

0 commit comments

Comments
 (0)