/
format-html-shared.ts
104 lines (92 loc) · 2.85 KB
/
format-html-shared.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
* format-html-shared.ts
*
* Copyright (C) 2020 by RStudio, PBC
*
*/
import { join } from "path/mod.ts";
import { outputVariable, sassVariable } from "../../core/sass.ts";
import { kCodeOverflow } from "../../config/constants.ts";
import { Format, FormatDependency } from "../../config/types.ts";
import { formatResourcePath } from "../../core/resources.ts";
export const kCodeCopy = "code-copy";
export const kAnchorSections = "anchor-sections";
export const kPageLayout = "page-layout";
export const kPageLayoutArticle = "article";
export const kPageLayoutCustom = "custom";
export const kPageLayoutNone = "none";
export const kHoverCitations = "hover-citations";
export const kHoverFootnotes = "hover-footnotes";
export const kComments = "comments";
export const kHypothesis = "hypothesis";
export const kUtterances = "utterances";
export const kFootnoteSectionTitle = "footnote-section-title";
export const kDocumentCss = "document-css";
export const kBootstrapDependencyName = "bootstrap";
export const clipboardDependency = () => {
const dependency: FormatDependency = { name: "clipboard" };
dependency.scripts = [];
dependency.scripts.push({
name: "clipboard.min.js",
path: formatResourcePath("html", join("clipboard", "clipboard.min.js")),
});
return dependency;
};
export const quartoRules = () =>
Deno.readTextFileSync(formatResourcePath(
"html",
"_quarto-rules.scss",
));
export const quartoGlobalCssVariableRules = () => {
return `
$font-family-monospace: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace !default;
/*! quarto-variables-start */
:root {
--quarto-font-monospace: #{inspect($font-family-monospace)};
}
/*! quarto-variables-end */
`;
};
export const quartoBootstrapRules = () =>
Deno.readTextFileSync(formatResourcePath(
"html",
join("bootstrap", "_bootstrap-rules.scss"),
));
export const quartoBootstrapMixins = () =>
Deno.readTextFileSync(formatResourcePath(
"html",
join("bootstrap", "_bootstrap-mixins.scss"),
));
export const quartoBootstrapFunctions = () =>
Deno.readTextFileSync(formatResourcePath(
"html",
join("bootstrap", "_bootstrap-functions.scss"),
));
export const quartoFunctions = () =>
Deno.readTextFileSync(formatResourcePath(
"html",
"_quarto-functions.scss",
));
export const quartoDefaults = (format: Format) => {
const defaults: string[] = [];
defaults.push(
outputVariable(
sassVariable(
"code-copy-selector",
format.metadata[kCodeCopy] === undefined ||
format.metadata[kCodeCopy] === "hover"
? '"pre.sourceCode:hover > "'
: '""',
),
),
);
defaults.push(
outputVariable(
sassVariable(
"code-white-space",
format.render[kCodeOverflow] === "wrap" ? "pre-wrap" : "pre",
),
),
);
return defaults.join("\n");
};