Skip to content

Commit

Permalink
Merge branch 'main' into fix/issue11664
Browse files Browse the repository at this point in the history
  • Loading branch information
mcanouil authored Jan 31, 2025
2 parents f0fc230 + ca05876 commit 8117731
Show file tree
Hide file tree
Showing 56 changed files with 659 additions and 181 deletions.
2 changes: 2 additions & 0 deletions news/changelog-1.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ All changes included in 1.7:
- ([#11580](https://github.com/quarto-dev/quarto-cli/issues/11580)): Fix regression with documents containing `categories` fields that are not strings.
- ([#11752](https://github.com/quarto-dev/quarto-cli/issues/11752)): Fix regression with non-alphanumeric characters in `categories` preventing correct filtering of listing.
- ([#11561](https://github.com/quarto-dev/quarto-cli/issues/11561)): Fix a regression with `$border-color` that impacted, callouts borders, tabset borders, and table borders of the defaults themes. `$border-color` is now correctly a mixed of `$body-color` and `$body-bg` even for the default theme.
- ([#11943](https://github.com/quarto-dev/quarto-cli/issues/11943)): Fix callout title color on dark theme in revealjs following Revealjs update in quarto 1.6.

## YAML validation

Expand Down Expand Up @@ -44,6 +45,7 @@ All changes included in 1.7:
- ([#11578](https://github.com/quarto-dev/quarto-cli/issues/11578)): Typst column layout widths use fractional `fr` units instead of percent `%` units for unitless and default widths in order to fill the enclosing block and not spill outside it.
- ([#11676](https://github.com/quarto-dev/quarto-cli/pull/11676)): Convert unitless image widths from pixels to inches for column layouts.
- ([#11835](https://github.com/quarto-dev/quarto-cli/issues/11835)): Take markdown structure into account when detecting minimum heading level.
- ([#11964](https://github.com/quarto-dev/quarto-cli/issues/11964)): Using panel layout without a crossref label now correctly do not add an empty `#block[]` that was leading to an unnecessary space in output.

## Lua Filters and extensions

Expand Down
4 changes: 2 additions & 2 deletions package/src/common/cyclic-dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { runCmd } from "../util/cmd.ts";
import { Configuration, readConfiguration } from "./config.ts";
import { error, info } from "../../../src/deno_ral/log.ts";
import { progressBar } from "../../../src/core/console.ts";
import { md5Hash } from "../../../src/core/hash.ts";
import { md5HashSync } from "../../../src/core/hash.ts";

export function cycleDependenciesCommand() {
return new Command()
Expand Down Expand Up @@ -186,7 +186,7 @@ function findCyclicDependencies(
// creates a hash for a set of paths (a cycle)
const hash = (paths: string[]) => {
const string = paths.join(" ");
return md5Hash(string);
return md5HashSync(string);
};

// The current import stack
Expand Down
8 changes: 5 additions & 3 deletions package/src/common/patches/revealjs-theme-0001-dracula.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
diff --git a/src/resources/formats/revealjs/themes/dracula.scss b/src/resources/formats/revealjs/themes/dracula.scss
index 5330fbc1b..45498dd41 100644
index 5330fbc1b..fe068d9a8 100644
--- a/src/resources/formats/revealjs/themes/dracula.scss
+++ b/src/resources/formats/revealjs/themes/dracula.scss
@@ -1,106 +1,88 @@
@@ -1,106 +1,90 @@
/**
* Dracula Dark theme for reveal.js.
* Based on https://draculatheme.com
Expand Down Expand Up @@ -151,7 +151,9 @@ index 5330fbc1b..45498dd41 100644
- }
+ strong,
+ b {
+ color: var(--r-bold-color);
+ &:not(.callout-title strong, .callout-tile b) {
+ color: var(--r-bold-color);
+ }
+ }
+ em,
+ i,
Expand Down
4 changes: 3 additions & 1 deletion package/src/common/update-html-dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,9 @@ async function updateGithubSourceCodeDependency(
await unzip(zipFile, working);

await onDownload(working, version);
if (patches) await applyGitPatches(patches);
if (patches) {
await applyGitPatches(patches);
}
} else {
throw new Error(`${versionEnvVar} is not defined`);
}
Expand Down
2 changes: 1 addition & 1 deletion src/command/preview/cmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ export const previewCommand = new Command()
// get project and preview format
const nbContext = notebookContext();
const project = (await projectContext(dirname(file), nbContext)) ||
singleFileProjectContext(file, nbContext);
(await singleFileProjectContext(file, nbContext));
const formats = await (async () => {
const services = renderServices(nbContext);
try {
Expand Down
4 changes: 3 additions & 1 deletion src/command/preview/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ export async function previewFormat(
return format;
}
const nbContext = notebookContext();
project = project || singleFileProjectContext(file, nbContext);
project = project || (await singleFileProjectContext(file, nbContext));
formats = formats ||
await withRenderServices(
nbContext,
Expand Down Expand Up @@ -485,6 +485,8 @@ export async function renderForPreview(
[],
));

renderResult.context.cleanup();

return {
file,
format: renderResult.files[0].format,
Expand Down
2 changes: 1 addition & 1 deletion src/command/publish/cmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ async function createPublishOptions(

// check for directory (either website or single-file project)
const project = (await projectContext(path, nbContext)) ||
singleFileProjectContext(path, nbContext);
(await singleFileProjectContext(path, nbContext));
if (Deno.statSync(path).isDirectory) {
if (projectIsWebsite(project)) {
input = project;
Expand Down
8 changes: 8 additions & 0 deletions src/command/render/cmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ export const renderCommand = new Command()
const services = renderServices(notebookContext());
try {
renderResultInput = relative(Deno.cwd(), walk.path) || ".";
if (renderResult) {
renderResult.context.cleanup();
}
renderResult = await render(renderResultInput, {
services,
flags,
Expand All @@ -255,6 +258,7 @@ export const renderCommand = new Command()

// check for error
if (renderResult.error) {
renderResult.context.cleanup();
throw renderResult.error;
}
} finally {
Expand All @@ -275,6 +279,10 @@ export const renderCommand = new Command()
if (finalOutput) {
info("Output created: " + finalOutput + "\n");
}

if (renderResult) {
renderResult.context.cleanup();
}
}
} else {
throw new Error(`No valid input files passed to render`);
Expand Down
9 changes: 6 additions & 3 deletions src/command/render/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@ export async function generateDefaults(
let allDefaults: FormatPandoc | undefined;

if (options.format.pandoc) {
allDefaults = (options.format.pandoc
? ld.cloneDeep(options.format.pandoc)
: {}) as FormatPandoc;
allDefaults = {
...(options.format.pandoc || {}),
variables: {
...(options.format.pandoc?.variables || {}),
},
} as FormatPandoc;

// resolve filters
const resolvedFilters = await resolveFilters(
Expand Down
1 change: 1 addition & 0 deletions src/command/render/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@ function initFilterParams(dependenciesFile: string) {
const kQuartoFilterMarker = "quarto";
const kQuartoCiteProcMarker = "citeproc";

// NB: this mutates `pandoc.citeproc`
export async function resolveFilters(
filters: QuartoFilter[],
options: PandocOptions,
Expand Down
9 changes: 6 additions & 3 deletions src/command/render/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ import {
import { isQuartoMetadata } from "../../config/metadata.ts";
import { RenderFlags, RenderOptions } from "./types.ts";

import * as ld from "../../core/lodash.ts";

import { isAbsolute, SEP_PATTERN } from "../../deno_ral/path.ts";
import { normalizePath } from "../../core/path.ts";
import { removeFlags } from "../../core/flags.ts";
Expand Down Expand Up @@ -471,7 +469,12 @@ export function removePandocToArg(args: string[]) {
}

export function removePandocTo(renderOptions: RenderOptions) {
renderOptions = ld.cloneDeep(renderOptions);
renderOptions = {
...renderOptions,
flags: {
...(renderOptions.flags || {}),
},
} as RenderOptions;
delete renderOptions.flags?.to;
if (renderOptions.pandocArgs) {
renderOptions.pandocArgs = removePandocToArg(renderOptions.pandocArgs);
Expand Down
20 changes: 10 additions & 10 deletions src/command/render/freeze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ import {
LF,
} from "../../deno_ral/fs.ts";

import { cloneDeep } from "../../core/lodash.ts";

import { inputFilesDir } from "../../core/render.ts";
import { TempContext } from "../../core/temp.ts";
import { md5Hash } from "../../core/hash.ts";
import { md5HashSync } from "../../core/hash.ts";
import {
normalizePath,
removeIfEmptyDir,
Expand Down Expand Up @@ -55,13 +53,15 @@ export function freezeExecuteResult(
result: ExecuteResult,
) {
// resolve includes within executeResult
result = cloneDeep(result) as ExecuteResult;
const innerResult = {
...result,
} as ExecuteResult;
const resolveIncludes = (
name: "include-in-header" | "include-before-body" | "include-after-body",
) => {
if (result.includes) {
if (result.includes[name]) {
result.includes[name] = result.includes[name]!.map((file) =>
if (innerResult.includes) {
if (innerResult.includes[name]) {
innerResult.includes[name] = innerResult.includes[name]!.map((file) =>
// Storing file content using LF line ending
format(Deno.readTextFileSync(file), LF)
);
Expand All @@ -73,7 +73,7 @@ export function freezeExecuteResult(
resolveIncludes(kIncludeAfterBody);

// make the supporting dirs relative to the input file dir
result.supporting = result.supporting.map((file) => {
innerResult.supporting = innerResult.supporting.map((file) => {
if (isAbsolute(file)) {
return relative(normalizePath(dirname(input)), file);
} else {
Expand All @@ -88,7 +88,7 @@ export function freezeExecuteResult(
const freezeJsonFile = freezeResultFile(input, output, true);
Deno.writeTextFileSync(
freezeJsonFile,
JSON.stringify({ hash, result }, undefined, 2),
JSON.stringify({ hash, result: innerResult }, undefined, 2),
);

// return the file
Expand Down Expand Up @@ -310,7 +310,7 @@ export function removeFreezeResults(filesDir: string) {
function freezeInputHash(input: string) {
// Calculate the hash on a content with LF line ending to avoid
// different hash on different OS (#3599)
return md5Hash(format(Deno.readTextFileSync(input), LF));
return md5HashSync(format(Deno.readTextFileSync(input), LF));
}

// don't use _files suffix in freezer
Expand Down
16 changes: 8 additions & 8 deletions src/command/render/pandoc-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export async function resolveSassBundles(
inputDir: string,
extras: FormatExtras,
format: Format,
temp: TempContext,
project: ProjectContext,
) {
extras = cloneDeep(extras);
Expand Down Expand Up @@ -159,11 +158,11 @@ export async function resolveSassBundles(

for (const target of targets) {
let cssPath: string | undefined;
cssPath = await compileSass(target.bundles, temp);
cssPath = await compileSass(target.bundles, project);
// First, Clean CSS
cleanSourceMappingUrl(cssPath);
// look for a sentinel 'dark' value, extract variables
const cssResult = await processCssIntoExtras(cssPath, extras, temp);
const cssResult = await processCssIntoExtras(cssPath, extras, project);
cssPath = cssResult.path;

// it can happen that processing generate an empty css file (e.g quarto-html deps with Quarto CSS variables)
Expand Down Expand Up @@ -261,7 +260,7 @@ export async function resolveSassBundles(
inputDir,
extras,
format,
temp,
project,
hasDarkStyles ? "light" : "default",
defaultStyle,
);
Expand All @@ -272,7 +271,7 @@ export async function resolveSassBundles(
inputDir,
extras,
format,
temp,
project,
"dark",
defaultStyle,
);
Expand All @@ -291,7 +290,7 @@ async function resolveQuartoSyntaxHighlighting(
inputDir: string,
extras: FormatExtras,
format: Format,
temp: TempContext,
project: ProjectContext,
style: "dark" | "light" | "default",
defaultStyle?: "dark" | "light",
) {
Expand Down Expand Up @@ -381,7 +380,7 @@ async function resolveQuartoSyntaxHighlighting(
rules: rules.join("\n"),
},
}],
temp,
project,
false,
);

Expand Down Expand Up @@ -500,8 +499,9 @@ interface CSSResult {
async function processCssIntoExtras(
cssPath: string,
extras: FormatExtras,
temp: TempContext,
project: ProjectContext,
): Promise<CSSResult> {
const { temp } = project;
extras.html = extras.html || {};

const css = Deno.readTextFileSync(cssPath);
Expand Down
Loading

0 comments on commit 8117731

Please sign in to comment.