Skip to content

Commit 10e5d01

Browse files
committed
Merge branch 'main' of github.com:quarto-dev/quarto-cli into main
2 parents 3e20cba + ed096bb commit 10e5d01

File tree

13 files changed

+76
-42
lines changed

13 files changed

+76
-42
lines changed

src/command/render/pandoc.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,7 @@ import {
153153
parsePandocDate,
154154
parseSpecialDate,
155155
} from "../../core/date.ts";
156-
import { copyFileIfNewer } from "../../core/copy.ts";
157156
import { katexPostProcessor } from "../../format/html/format-html-math.ts";
158-
import { lines } from "../../core/lib/text.ts";
159157
import {
160158
readAndInjectDependencies,
161159
writeDependencies,
@@ -860,25 +858,31 @@ export async function runPandoc(
860858
},
861859
);
862860

863-
// TODO: Process Dependencies
864-
865861
// resolve resource files from metadata
866862
const resources: string[] = resourcesFromMetadata(
867863
options.format.metadata[kResources],
868864
);
869865

870866
// read any resourceFiles generated by filters
867+
let inputTraits = {};
871868
if (existsSync(filterResultsFile)) {
872869
const filterResultsJSON = Deno.readTextFileSync(filterResultsFile);
873870
if (filterResultsJSON.trim().length > 0) {
874871
const filterResults = JSON.parse(filterResultsJSON);
875-
resources.push(...(filterResults.resourceFiles || []));
872+
873+
// Read any input traits
874+
inputTraits = filterResults.inputTraits;
875+
876+
// Read any resource files
877+
const resourceFiles = filterResults.resourceFiles || [];
878+
resources.push(...resourceFiles);
876879
}
877880
}
878881

879882
if (result.success) {
880883
return {
881884
inputMetadata: pandocMetadata,
885+
inputTraits,
882886
resources,
883887
postprocessors,
884888
htmlPostprocessors: isHtmlOutput(options.format.pandoc)

src/command/render/render.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ import {
2222
executionEngineKeepMd,
2323
} from "../../execute/engine.ts";
2424

25-
import { HtmlPostProcessResult, PandocOptions } from "./types.ts";
25+
import {
26+
HtmlPostProcessor,
27+
HtmlPostProcessResult,
28+
PandocInputTraits,
29+
PandocOptions,
30+
} from "./types.ts";
2631
import { runPandoc } from "./pandoc.ts";
2732
import { renderCleanup } from "./cleanup.ts";
2833
import { projectOffset } from "../../project/project-shared.ts";
@@ -140,6 +145,7 @@ export async function renderPandoc(
140145

141146
const htmlPostProcessResult = await runHtmlPostprocessors(
142147
pandocResult.inputMetadata,
148+
pandocResult.inputTraits,
143149
pandocOptions,
144150
htmlPostProcessors,
145151
htmlFinalizers,
@@ -326,10 +332,9 @@ function mergePandocIncludes(
326332

327333
async function runHtmlPostprocessors(
328334
inputMetadata: Metadata,
335+
inputTraits: PandocInputTraits,
329336
options: PandocOptions,
330-
htmlPostprocessors: Array<
331-
(doc: Document, inputMetadata: Metadata) => Promise<HtmlPostProcessResult>
332-
>,
337+
htmlPostprocessors: Array<HtmlPostProcessor>,
333338
htmlFinalizers: Array<(doc: Document) => Promise<void>>,
334339
): Promise<HtmlPostProcessResult> {
335340
const postProcessResult: HtmlPostProcessResult = {
@@ -345,7 +350,7 @@ async function runHtmlPostprocessors(
345350
const doc = await parseHtml(htmlInput);
346351
for (let i = 0; i < htmlPostprocessors.length; i++) {
347352
const postprocessor = htmlPostprocessors[i];
348-
const result = await postprocessor(doc, inputMetadata);
353+
const result = await postprocessor(doc, inputMetadata, inputTraits);
349354

350355
postProcessResult.resources.push(...result.resources);
351356
postProcessResult.supporting.push(...result.supporting);

src/command/render/types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { Metadata } from "../../config/types.ts";
1717
import { ProjectContext } from "../../project/types.ts";
1818
import { TempContext } from "../../core/temp-types.ts";
1919
import { ExtensionContext } from "../../extension/extension-shared.ts";
20+
import { kPositionedRefs } from "../../config/constants.ts";
2021

2122
// options for render
2223
export interface RenderOptions {
@@ -49,15 +50,21 @@ export interface RenderContext {
4950

5051
export interface RunPandocResult {
5152
inputMetadata: Metadata;
53+
inputTraits: PandocInputTraits;
5254
resources: string[];
5355
postprocessors?: Array<(output: string) => Promise<void>>;
5456
htmlPostprocessors: Array<HtmlPostProcessor>;
5557
htmlFinalizers?: Array<(doc: Document) => Promise<void>>;
5658
}
5759

60+
export interface PandocInputTraits {
61+
[kPositionedRefs]?: boolean;
62+
}
63+
5864
export type HtmlPostProcessor = (
5965
doc: Document,
6066
inputMedata: Metadata,
67+
inputTraits: PandocInputTraits,
6168
) => Promise<HtmlPostProcessResult>;
6269

6370
export interface HtmlPostProcessResult {

src/config/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,9 @@ export const kTblCapLoc = "tbl-cap-location";
443443
export const kCapTop = "top";
444444
export const kCapBottom = "bottom";
445445

446+
// Pandoc Input Traits
447+
export const kPositionedRefs = "positioned-refs";
448+
446449
// https://pandoc.org/MANUAL.html#default-files
447450
// note: we are keeping some things out of 'defaults' b/ca
448451
// they are known to be valid in metadata. this includes:

src/core/lib/yaml-validation/schema-navigation.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ export function navigateSchemaBySchemaPathSingle(
111111

112112
// deno-lint-ignore no-explicit-any
113113
const inner = (subschema: any, index: number): any => {
114+
subschema = resolveSchema(subschema);
114115
if (subschema === undefined) {
115116
throw new Error(
116117
`Internal Error in navigateSchemaBySchemaPathSingle: invalid path navigation`,

src/format/html/format-html-appendix.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
*
66
*/
77

8+
import { PandocInputTraits } from "../../command/render/types.ts";
89
import {
910
kAppendixAttributionBibTex,
1011
kAppendixAttributionCiteAs,
1112
kLang,
13+
kPositionedRefs,
1214
kSectionTitleCitation,
1315
kSectionTitleReuse,
1416
} from "../../config/constants.ts";
@@ -51,6 +53,7 @@ const kAppendixId = "quarto-appendix";
5153

5254
export async function processDocumentAppendix(
5355
input: string,
56+
inputTraits: PandocInputTraits,
5457
format: Format,
5558
flags: PandocFlags,
5659
doc: Document,
@@ -102,7 +105,7 @@ export async function processDocumentAppendix(
102105
};
103106

104107
// Move the refs into the appendix
105-
if (!hasMarginCites(format)) {
108+
if (!hasMarginCites(format) && !inputTraits[kPositionedRefs]) {
106109
const refsEl = doc.getElementById("refs");
107110
if (refsEl) {
108111
const findRefTitle = (refsEl: Element) => {

src/format/html/format-html-bootstrap.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
kHtmlFinalizers,
2929
kHtmlPostprocessors,
3030
kSassBundles,
31+
Metadata,
3132
SassLayer,
3233
} from "../../config/types.ts";
3334
import { PandocFlags } from "../../config/types.ts";
@@ -49,6 +50,7 @@ import {
4950
import {
5051
HtmlPostProcessor,
5152
HtmlPostProcessResult,
53+
PandocInputTraits,
5254
} from "../../command/render/types.ts";
5355
import { processDocumentAppendix } from "./format-html-appendix.ts";
5456
import {
@@ -211,6 +213,8 @@ function bootstrapHtmlPostprocessor(
211213
): HtmlPostProcessor {
212214
return async (
213215
doc: Document,
216+
_inputMedata: Metadata,
217+
inputTraits: PandocInputTraits,
214218
): Promise<HtmlPostProcessResult> => {
215219
// use display-7 style for title
216220
const title = doc.querySelector("header > .title");
@@ -356,7 +360,7 @@ function bootstrapHtmlPostprocessor(
356360
format.metadata[kAppendixStyle] !== false &&
357361
format.metadata[kAppendixStyle] !== "none"
358362
) {
359-
await processDocumentAppendix(input, format, flags, doc, offset);
363+
await processDocumentAppendix(input, inputTraits, format, flags, doc, offset);
360364
}
361365

362366
// no resource refs

src/resources/editor/tools/vs-code.mjs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9668,11 +9668,7 @@ var require_yaml_intelligence_resources = __commonJS({
96689668
maybeArrayOf: {
96699669
anyOf: [
96709670
"string",
9671-
{
9672-
object: {
9673-
additionalProperties: true
9674-
}
9675-
}
9671+
"object"
96769672
]
96779673
},
96789674
description: "The files or path globs of Quarto documents or YAML files that should be included in the listing."
@@ -16902,6 +16898,7 @@ var require_yaml_intelligence_resources = __commonJS({
1690216898
"Re-render input files when they change (defaults to true)",
1690316899
"Navigate the browser automatically when outputs are updated (defaults\nto true)",
1690416900
"Time (in seconds) after which to exit if there are no active\nclients",
16901+
"Sites published from project",
1690516902
"Unique identifier for site",
1690616903
"Published URL for site",
1690716904
"Website title",
@@ -18385,7 +18382,6 @@ var require_yaml_intelligence_resources = __commonJS({
1838518382
"Additional file resources to be copied to output directory",
1838618383
"Additional file resources to be copied to output directory",
1838718384
"Options for <code>quarto preview</code>",
18388-
"Sites published from project",
1838918385
"MISSING_DESCRIPTION",
1839018386
"MISSING_DESCRIPTION",
1839118387
"Book title",
@@ -18585,7 +18581,6 @@ var require_yaml_intelligence_resources = __commonJS({
1858518581
"Additional file resources to be copied to output directory",
1858618582
"Additional file resources to be copied to output directory",
1858718583
"Options for <code>quarto preview</code>",
18588-
"Sites published from project",
1858918584
"MISSING_DESCRIPTION",
1859018585
"MISSING_DESCRIPTION",
1859118586
"Book title",
@@ -18771,8 +18766,7 @@ var require_yaml_intelligence_resources = __commonJS({
1877118766
"Download buttons for other formats to include on navbar or sidebar\n(one or more of <code>pdf</code>, <code>epub</code>, and `docx)",
1877218767
"Download buttons for other formats to include on navbar or sidebar\n(one or more of <code>pdf</code>, <code>epub</code>, and `docx)",
1877318768
"Custom tools for navbar or sidebar",
18774-
"internal-schema-hack",
18775-
"Sites published from project"
18769+
"internal-schema-hack"
1877618770
],
1877718771
"schema/external-schemas.yml": [
1877818772
{
@@ -24250,6 +24244,7 @@ function navigateSchemaBySchemaPathSingle(schema2, path) {
2425024244
}
2425124245
};
2425224246
const inner = (subschema, index) => {
24247+
subschema = resolveSchema(subschema);
2425324248
if (subschema === void 0) {
2425424249
throw new Error(`Internal Error in navigateSchemaBySchemaPathSingle: invalid path navigation`);
2425524250
}
@@ -25013,6 +25008,7 @@ function createLocalizedError(obj) {
2501325008
end: { line: 0, column: 0 }
2501425009
};
2501525010
}
25011+
console.log({ schemaPath });
2501625012
return {
2501725013
source: mappedString(source, [{
2501825014
start: violatingObject.start,

src/resources/editor/tools/yaml/web-worker.js

Lines changed: 5 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/resources/editor/tools/yaml/yaml-intelligence-resources.json

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2647,11 +2647,7 @@
26472647
"maybeArrayOf": {
26482648
"anyOf": [
26492649
"string",
2650-
{
2651-
"object": {
2652-
"additionalProperties": true
2653-
}
2654-
}
2650+
"object"
26552651
]
26562652
},
26572653
"description": "The files or path globs of Quarto documents or YAML files that should be included in the listing."
@@ -9881,6 +9877,7 @@
98819877
"Re-render input files when they change (defaults to true)",
98829878
"Navigate the browser automatically when outputs are updated (defaults\nto true)",
98839879
"Time (in seconds) after which to exit if there are no active\nclients",
9880+
"Sites published from project",
98849881
"Unique identifier for site",
98859882
"Published URL for site",
98869883
"Website title",
@@ -11364,7 +11361,6 @@
1136411361
"Additional file resources to be copied to output directory",
1136511362
"Additional file resources to be copied to output directory",
1136611363
"Options for <code>quarto preview</code>",
11367-
"Sites published from project",
1136811364
"MISSING_DESCRIPTION",
1136911365
"MISSING_DESCRIPTION",
1137011366
"Book title",
@@ -11564,7 +11560,6 @@
1156411560
"Additional file resources to be copied to output directory",
1156511561
"Additional file resources to be copied to output directory",
1156611562
"Options for <code>quarto preview</code>",
11567-
"Sites published from project",
1156811563
"MISSING_DESCRIPTION",
1156911564
"MISSING_DESCRIPTION",
1157011565
"Book title",
@@ -11750,8 +11745,7 @@
1175011745
"Download buttons for other formats to include on navbar or sidebar\n(one or more of <code>pdf</code>, <code>epub</code>, and `docx)",
1175111746
"Download buttons for other formats to include on navbar or sidebar\n(one or more of <code>pdf</code>, <code>epub</code>, and `docx)",
1175211747
"Custom tools for navbar or sidebar",
11753-
"internal-schema-hack",
11754-
"Sites published from project"
11748+
"internal-schema-hack"
1175511749
],
1175611750
"schema/external-schemas.yml": [
1175711751
{

0 commit comments

Comments
 (0)