Skip to content

Commit 82dded6

Browse files
committed
Merge branch 'main' of github.com:quarto-dev/quarto-cli into main
2 parents c7bb343 + ffd8ef8 commit 82dded6

File tree

9 files changed

+76
-19
lines changed

9 files changed

+76
-19
lines changed

src/command/render/filters.ts

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ export function removeFilterParmas(metadata: Metadata) {
108108
delete metadata[kQuartoParams];
109109
}
110110

111+
export function quartoInitFilter() {
112+
return resourcePath("filters/quarto-init/quarto-init.lua");
113+
}
114+
111115
export function quartoPreFilter() {
112116
return resourcePath("filters/quarto-pre/quarto-pre.lua");
113117
}
@@ -491,14 +495,21 @@ export function resolveFilters(
491495
options: PandocOptions,
492496
): QuartoFilter[] | undefined {
493497
// build list of quarto filters
498+
499+
// The default order of filters will be
500+
// quarto-init
501+
// quarto-authors
502+
// user filters
503+
// extension filters
504+
// quarto-filters <quarto>
505+
// citeproc
506+
// quarto-finalizer
507+
494508
const quartoFilters: string[] = [];
495509
quartoFilters.push(quartoPreFilter());
496510
if (crossrefFilterActive(options)) {
497511
quartoFilters.push(crossrefFilter());
498512
}
499-
if (authorsFilterActive(options)) {
500-
quartoFilters.push(authorsFilter());
501-
}
502513
quartoFilters.push(layoutFilter());
503514
quartoFilters.push(quartoPostFilter());
504515

@@ -519,19 +530,27 @@ export function resolveFilters(
519530
...filters.slice(quartoLoc + 1),
520531
];
521532
} else {
522-
filters.unshift(...quartoFilters);
533+
filters.push(...quartoFilters);
534+
}
535+
536+
// The author filter, if enabled
537+
if (authorsFilterActive(options)) {
538+
filters.unshift(authorsFilter());
523539
}
524540

541+
// The initializer for Quarto
542+
filters.unshift(quartoInitFilter());
543+
544+
// The finalizer for Quarto
545+
filters.push(quartoFinalizeFilter());
546+
525547
// citeproc at the very end so all other filters can interact with citations
526548
filters = filters.filter((filter) => filter !== "citeproc");
527549
const citeproc = citeMethod(options) === "citeproc";
528550
if (citeproc) {
529551
filters.push("citeproc");
530552
}
531553

532-
// The finalizer for Quarto
533-
filters.push(quartoFinalizeFilter());
534-
535554
// return filters
536555
if (filters.length > 0) {
537556
return filters;

src/command/tools/tools/tinytex.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ This will instruct TeX Live to create symlinks that it needs in <bin_dir_on_path
335335
const envPath = Deno.env.get("QUARTO_TEXLIVE_BINPATH");
336336
if (envPath) {
337337
paths.push(envPath);
338-
} else {
338+
} else if (Deno.build.os !== "windows") {
339339
paths.push(...suggestUserBinPaths());
340340
}
341341
const binPathMessage = envPath
@@ -359,7 +359,7 @@ This will instruct TeX Live to create symlinks that it needs in <bin_dir_on_path
359359
}
360360
}
361361
}
362-
if (!result?.success) {
362+
if (result && !result.success) {
363363
warning(message);
364364
}
365365
},

src/extension/extension-shared.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
*/
77
import SemVer from "semver/mod.ts";
8-
import { Metadata } from "../config/types.ts";
8+
import { Metadata, PandocFilter } from "../config/types.ts";
99
import { ProjectContext } from "../project/types.ts";
1010

1111
export const kCommon = "common";
@@ -24,7 +24,7 @@ export interface Extension extends Record<string, unknown> {
2424
path: string;
2525
contributes: {
2626
shortcodes?: string[];
27-
filters?: string[];
27+
filters?: PandocFilter[];
2828
format?: Record<string, unknown>;
2929
};
3030
}

src/extension/extension.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { kProjectType, ProjectContext } from "../project/types.ts";
1313
import { isSubdir } from "fs/_util.ts";
1414

1515
import { dirname, join, normalize } from "path/mod.ts";
16-
import { Metadata } from "../config/types.ts";
16+
import { Metadata, PandocFilter } from "../config/types.ts";
1717
import { resolvePathGlobs } from "../core/path.ts";
1818
import { toInputRelativePaths } from "../project/project-shared.ts";
1919
import { projectType } from "../project/types/project-types.ts";
@@ -355,7 +355,7 @@ function readExtension(
355355

356356
// The items that can be contributed
357357
const shortcodes = contributes?.shortcodes as string[] || [];
358-
const filters = contributes?.filters as string[] || [];
358+
const filters = contributes?.filters as PandocFilter[] || [];
359359
const format = contributes?.format as Metadata || [];
360360

361361
// Process the special 'common' key by merging it

src/project/types/website/website-meta.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ export function metadataHtmlPostProcessor(
149149
},
150150
};
151151

152+
// Resources that we find during this post processing
153+
const resources: string[] = [];
154+
152155
// go through each metadata provider and emit metadata
153156
[
154157
openGraphMetadataProvider,
@@ -180,7 +183,10 @@ export function metadataHtmlPostProcessor(
180183
}
181184

182185
// Convert image to absolute href and add height and width
183-
resolveImageMetadata(source, project, format, metadata);
186+
const imagePath = resolveImageMetadata(source, project, format, metadata);
187+
if (imagePath) {
188+
resources.push(imagePath);
189+
}
184190

185191
// Allow the provider to resolve any defaults
186192
if (provider.resolveDefaults) {
@@ -209,7 +215,10 @@ export function metadataHtmlPostProcessor(
209215
// Process any pipelined markdown
210216
pipeline.processRenderedMarkdown(doc);
211217

212-
return Promise.resolve(kHtmlEmptyPostProcessResult);
218+
return Promise.resolve({
219+
resources,
220+
supporting: [],
221+
});
213222
};
214223
}
215224

@@ -296,6 +305,8 @@ function resolveImageMetadata(
296305
if (altText && !metadata[kImageAlt]) {
297306
metadata[kImageAlt] = altText;
298307
}
308+
309+
return imgMeta.path;
299310
}
300311
}
301312

@@ -348,6 +359,7 @@ function imageMetadata(
348359

349360
// read the image size
350361
return {
362+
path: image,
351363
href: `${baseUrl}${image}`,
352364
height: size?.height,
353365
width: size?.width,
@@ -364,6 +376,7 @@ function imageMetadata(
364376

365377
// resolve the image path into an absolute href
366378
return {
379+
path: imageProjectRelative,
367380
href: joinUrl(baseUrl, imageProjectRelative),
368381
height: size?.height,
369382
width: size?.width,
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
-- quarto-init.lua
2+
-- Copyright (C) 2020 by RStudio, PBC
3+
4+
-- required version
5+
PANDOC_VERSION:must_be_at_least '2.13'
6+
7+
-- [import]
8+
function import(script)
9+
local path = PANDOC_SCRIPT_FILE:match("(.*[/\\])")
10+
dofile(path .. script)
11+
end
12+
import("../common/base64.lua")
13+
import("../common/filemetadata.lua")
14+
import("../common/meta.lua")
15+
import("../common/params.lua")
16+
import("includes.lua")
17+
import("resourcerefs.lua")
18+
-- [/import]
19+
20+
-- initialize params
21+
initParams()
22+
23+
return {
24+
readIncludes(),
25+
resourceRefs(),
26+
}
27+
28+
29+

src/resources/filters/quarto-pre/quarto-pre.lua

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ import("../common/log.lua")
5050
import("../common/url.lua")
5151
import("../common/paths.lua")
5252
import("results.lua")
53-
import("includes.lua")
5453
import("options.lua")
5554
import("shortcodes.lua")
5655
import("shortcodes-handlers.lua")
@@ -60,7 +59,6 @@ import("table-rawhtml.lua")
6059
import("table-captions.lua")
6160
import("table-colwidth.lua")
6261
import("theorems.lua")
63-
import("resourcerefs.lua")
6462
import("resourcefiles.lua")
6563
import("book-numbering.lua")
6664
import("book-links.lua")
@@ -83,7 +81,6 @@ initParams()
8381
initShortcodeHandlers()
8482

8583
return {
86-
readIncludes(),
8784
initOptions(),
8885
shortCodesBlocks(),
8986
shortCodesInlines(),
@@ -101,7 +98,6 @@ return {
10198
indexBookFileTargets(),
10299
bookNumbering(),
103100
includePaths(),
104-
resourceRefs(),
105101
resourceFiles(),
106102
figures(),
107103
theorems(),

0 commit comments

Comments
 (0)