Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
quarto-dev
GitHub Repository: quarto-dev/quarto-cli
Path: blob/main/src/command/render/pandoc-dependencies.ts
3583 views
1
/*
2
* pandoc-dependencies.ts
3
*
4
* Copyright (C) 2020-2022 Posit Software, PBC
5
*/
6
7
import { DependencyFile, FormatDependency } from "../../config/types.ts";
8
import { appendTextFile } from "../../core/file.ts";
9
10
export interface HtmlFormatDependency {
11
type: "html";
12
content: FormatDependency;
13
}
14
15
export interface HtmlAttachmentDependency {
16
type: "html-attachment";
17
content: {
18
name: string;
19
file: DependencyFile;
20
};
21
}
22
23
export interface FormatResourceDependency {
24
type: "format-resources";
25
content: {
26
file: string;
27
};
28
}
29
30
export interface TextDependency {
31
type: "text";
32
content: {
33
text: string;
34
location: "before-body" | "after-body" | "in-header";
35
};
36
}
37
38
export interface FileDependency {
39
type: "file";
40
content: {
41
path: string;
42
};
43
}
44
45
export interface UsePackageDependency {
46
type: "usepackage";
47
content: {
48
package: string;
49
options: string;
50
};
51
}
52
53
export async function appendDependencies(
54
dependenciesFile: string,
55
dependencies: Array<
56
| HtmlFormatDependency
57
| HtmlAttachmentDependency
58
| FormatResourceDependency
59
| TextDependency
60
| FileDependency
61
| UsePackageDependency
62
>,
63
) {
64
const dependencyLines: string[] = [];
65
for (const dependency of dependencies) {
66
dependencyLines.push(
67
JSON.stringify(dependency),
68
);
69
}
70
if (dependencyLines.length > 0) {
71
await appendTextFile(
72
dependenciesFile,
73
`${dependencyLines.join("\n")}\n`,
74
);
75
}
76
}
77
78