Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
quarto-dev
GitHub Repository: quarto-dev/quarto-cli
Path: blob/main/tests/smoke/render/render-text-highlighting.ts
12925 views
1
/*
2
* render-text-highlighting.test.ts
3
*
4
* Copyright (C) 2020-2022 Posit Software, PBC
5
*
6
*/
7
import { docs, outputForInput } from "../../utils.ts";
8
import { ensureFileRegexMatches } from "../../verify.ts";
9
import { testRender } from "./render.ts";
10
11
const codeblockBg = (color: string) => {
12
return new RegExp(
13
`div.sourceCode pre.sourceCode {[\r\n]+\s*color: ${color};`,
14
"gm",
15
);
16
};
17
18
const tests = [
19
{
20
to: "html",
21
input: docs("text-highlighting/default.qmd"),
22
match: codeblockBg("#00769E"),
23
},
24
{
25
to: "html",
26
input: docs("text-highlighting/dark.qmd"),
27
match: codeblockBg("#f8f8f2"),
28
},
29
{
30
to: "html",
31
input: docs("text-highlighting/github-dark.qmd"),
32
match: codeblockBg("#e1e4e8"),
33
},
34
{
35
to: "html",
36
input: docs("text-highlighting/user-simple.qmd"),
37
nomatch: codeblockBg("#f8f8f8"),
38
},
39
{
40
to: "html",
41
input: docs("text-highlighting/user-complex.qmd"),
42
nomatch: codeblockBg("#2a211c"),
43
},
44
{
45
to: "latex",
46
input: docs("text-highlighting/github-pdf.qmd"),
47
match: /begin{tcolorbox}/,
48
},
49
{
50
to: "latex",
51
input: docs("text-highlighting/vimdark-pdf.qmd"),
52
match: /definecolor{shadecolor}{RGB}{0,0,0}/,
53
},
54
];
55
56
tests.forEach((test) => {
57
const output = outputForInput(test.input, test.to);
58
testRender(test.input, test.to, test.to !== "html", [
59
ensureFileRegexMatches(
60
output.outputPath,
61
test.match ? [test.match] : [],
62
test.nomatch ? [test.nomatch] : [],
63
),
64
]);
65
});
66
67