Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
quarto-dev
GitHub Repository: quarto-dev/quarto-cli
Path: blob/main/tests/smoke/render/render-callout.test.ts
12921 views
1
/*
2
* render-callout.test.ts
3
*
4
* Copyright (C) 2020-2022 Posit Software, PBC
5
*
6
*/
7
8
import { docs, outputForInput } from "../../utils.ts";
9
import {
10
ensureDocxRegexMatches,
11
ensureFileRegexMatches,
12
ensureHtmlElements,
13
requireLatexPackage,
14
} from "../../verify.ts";
15
import { testRender } from "./render.ts";
16
17
const input = docs("callouts.qmd");
18
const htmlOutput = outputForInput(input, "html");
19
20
testRender(input, "html", false, [
21
ensureHtmlElements(htmlOutput.outputPath, [
22
// callout environments are created
23
"div.callout-warning",
24
"div.callout-important",
25
"div.callout-note",
26
"div.callout-tip",
27
"div.callout-caution",
28
"div.callout.no-icon",
29
// formatting is kept in caption
30
"div.callout-tip > div.callout-header > div.callout-title-container > strong",
31
"div.callout-tip > div.callout-header > div.callout-title-container > code",
32
// appearance correctly modify structure
33
"#appearance div.callout-style-simple > div.callout-body > div.callout-icon-container + div.callout-body-container",
34
"#appearance div.callout-style-default.callout-titled > div.callout-header > div.callout-icon-container + div.callout-title-container",
35
"#appearance div.callout-style-default.callout-titled > div.callout-header + div.callout-body-container",
36
"#appearance div.callout-style-default.no-icon.callout-titled > div.callout-header > div.callout-icon-container > i.no-icon",
37
"#appearance div.callout-style-default.no-icon.callout-titled > div.callout-header > div.callout-icon-container + div.callout-title-container",
38
"#appearance div.callout-style-simple.no-icon > div.callout-body",
39
"#minimal div.callout-style-simple.no-icon > div.callout-body",
40
],
41
[
42
"#appearance div.callout-style-simple.no-icon > div.callout-header",
43
"#minimal div.callout-style-simple.no-icon > div.callout-header"
44
]),
45
]);
46
47
testRender(input, "revealjs", false, [
48
ensureHtmlElements(htmlOutput.outputPath, [
49
// callout environments are created
50
"div.callout-warning",
51
"div.callout-important",
52
"div.callout-note",
53
"div.callout-tip",
54
"div.callout-caution",
55
"div.callout.no-icon",
56
// formatting is kept in caption
57
"#markup div.callout-tip > div.callout-body > div.callout-title strong > code",
58
"#markup div.callout-caution > div.callout-body > div.callout-content code",
59
"#markup div.callout-none.no-icon.callout-titled.callout-style-simple > div.callout-body > div.callout-content code",
60
// appearance correctly modify structure
61
"#overview div.callout-style-default.callout-titled > div.callout-body > div.callout-title > div.callout-icon-container + p > strong", // default: title and icon correctly set
62
"#overview div.callout-style-default.callout-titled > div.callout-body > div.callout-title + div.callout-content", // default: title and content correctly set
63
"#appearance div.callout-style-simple > div.callout-body > div.callout-icon-container + div.callout-content", // simple: icon and content correctly set
64
"#appearance div.callout-style-default.callout-titled > div.callout-body > div.callout-title + div.callout-content", // default: title and content correctly set
65
"#appearance div.callout-style-default.no-icon.callout-titled > div.callout-body > div.callout-title + div.callout-content", // default no icon: title and content correctly set
66
"#appearance div.callout-style-simple.no-icon > div.callout-body", // simple no icon: content correctly set
67
"#minimal div.callout-style-simple.no-icon > div.callout-body > div.callout-content", // minimal
68
],
69
[
70
"#appearance div.callout-style-default.no-icon.callout-titled > div.callout-body > div.callout-title > div.callout-icon-container", // default no icon: title and content correctly set
71
"#appearance div.callout-style-simple.no-icon > div.callout-body > div.callout-icon-container", // simple no icon
72
"#minimal div.callout-style-simple.no-icon > div.callout-body > div.callout-icon-container"
73
]),
74
]);
75
76
const teXOutput = outputForInput(input, "latex");
77
testRender(input, "latex", true, [
78
ensureFileRegexMatches(teXOutput.outputPath, [
79
requireLatexPackage("fontawesome5"),
80
requireLatexPackage("tcolorbox", "skins,breakable"),
81
// callout environments are created
82
/quarto-callout-warning/,
83
/quarto-callout-important/,
84
/quarto-callout-note/,
85
/quarto-callout-tip/,
86
/quarto-callout-caution/,
87
// formatting is kept in caption,
88
/{Caption with \\textbf{formatted} text, like \\texttt{function\\_name\(\)}/,
89
]),
90
]);
91
92
const docXoutput = outputForInput(input, "docx");
93
testRender(input, "docx", true, [
94
ensureDocxRegexMatches(docXoutput.outputPath, [
95
// callout environments are created
96
/<pic:cNvPr.*warning\.png".*?\/>/,
97
/<pic:cNvPr.*important\.png".*?\/>/,
98
/<pic:cNvPr.*note\.png".*?\/>/,
99
/<pic:cNvPr.*tip\.png".*?\/>/,
100
/<pic:cNvPr.*caution\.png".*?\/>/,
101
// formatting is kept in caption,
102
/Caption with.*<w:bCs.*formatted.*text, like.*<w:rStyle w:val="VerbatimChar".*function_name\(\)/,
103
]),
104
]);
105
106
const crossRefInput = docs("crossrefs/callouts.qmd");
107
const crossRefOutput = outputForInput(crossRefInput, "latex");
108
testRender(crossRefInput, "latex", true, [
109
ensureFileRegexMatches(crossRefOutput.outputPath, [
110
// callout environments are created
111
/\\begin\{figure\}\[H\]/,
112
]),
113
]);
114
115