Path: blob/main/tests/smoke/render/render-callout.test.ts
12925 views
/*1* render-callout.test.ts2*3* Copyright (C) 2020-2022 Posit Software, PBC4*5*/67import { docs, outputForInput } from "../../utils.ts";8import {9ensureDocxRegexMatches,10ensureFileRegexMatches,11ensureHtmlElements,12requireLatexPackage,13} from "../../verify.ts";14import { testRender } from "./render.ts";1516const input = docs("callouts.qmd");17const htmlOutput = outputForInput(input, "html");1819testRender(input, "html", false, [20ensureHtmlElements(htmlOutput.outputPath, [21// callout environments are created22"div.callout-warning",23"div.callout-important",24"div.callout-note",25"div.callout-tip",26"div.callout-caution",27"div.callout.no-icon",28// formatting is kept in caption29"div.callout-tip > div.callout-header > div.callout-title-container > strong",30"div.callout-tip > div.callout-header > div.callout-title-container > code",31// appearance correctly modify structure32"#appearance div.callout-style-simple > div.callout-body > div.callout-icon-container + div.callout-body-container",33"#appearance div.callout-style-default.callout-titled > div.callout-header > div.callout-icon-container + div.callout-title-container",34"#appearance div.callout-style-default.callout-titled > div.callout-header + div.callout-body-container",35"#appearance div.callout-style-default.no-icon.callout-titled > div.callout-header > div.callout-icon-container > i.no-icon",36"#appearance div.callout-style-default.no-icon.callout-titled > div.callout-header > div.callout-icon-container + div.callout-title-container",37"#appearance div.callout-style-simple.no-icon > div.callout-body",38"#minimal div.callout-style-simple.no-icon > div.callout-body",39],40[41"#appearance div.callout-style-simple.no-icon > div.callout-header",42"#minimal div.callout-style-simple.no-icon > div.callout-header"43]),44]);4546testRender(input, "revealjs", false, [47ensureHtmlElements(htmlOutput.outputPath, [48// callout environments are created49"div.callout-warning",50"div.callout-important",51"div.callout-note",52"div.callout-tip",53"div.callout-caution",54"div.callout.no-icon",55// formatting is kept in caption56"#markup div.callout-tip > div.callout-body > div.callout-title strong > code",57"#markup div.callout-caution > div.callout-body > div.callout-content code",58"#markup div.callout-none.no-icon.callout-titled.callout-style-simple > div.callout-body > div.callout-content code",59// appearance correctly modify structure60"#overview div.callout-style-default.callout-titled > div.callout-body > div.callout-title > div.callout-icon-container + p > strong", // default: title and icon correctly set61"#overview div.callout-style-default.callout-titled > div.callout-body > div.callout-title + div.callout-content", // default: title and content correctly set62"#appearance div.callout-style-simple > div.callout-body > div.callout-icon-container + div.callout-content", // simple: icon and content correctly set63"#appearance div.callout-style-default.callout-titled > div.callout-body > div.callout-title + div.callout-content", // default: title and content correctly set64"#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 set65"#appearance div.callout-style-simple.no-icon > div.callout-body", // simple no icon: content correctly set66"#minimal div.callout-style-simple.no-icon > div.callout-body > div.callout-content", // minimal67],68[69"#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 set70"#appearance div.callout-style-simple.no-icon > div.callout-body > div.callout-icon-container", // simple no icon71"#minimal div.callout-style-simple.no-icon > div.callout-body > div.callout-icon-container"72]),73]);7475const teXOutput = outputForInput(input, "latex");76testRender(input, "latex", true, [77ensureFileRegexMatches(teXOutput.outputPath, [78requireLatexPackage("fontawesome5"),79requireLatexPackage("tcolorbox", "skins,breakable"),80// callout environments are created81/quarto-callout-warning/,82/quarto-callout-important/,83/quarto-callout-note/,84/quarto-callout-tip/,85/quarto-callout-caution/,86// formatting is kept in caption,87/{Caption with \\textbf{formatted} text, like \\texttt{function\\_name\(\)}/,88]),89]);9091const docXoutput = outputForInput(input, "docx");92testRender(input, "docx", true, [93ensureDocxRegexMatches(docXoutput.outputPath, [94// callout environments are created95/<pic:cNvPr.*warning\.png".*?\/>/,96/<pic:cNvPr.*important\.png".*?\/>/,97/<pic:cNvPr.*note\.png".*?\/>/,98/<pic:cNvPr.*tip\.png".*?\/>/,99/<pic:cNvPr.*caution\.png".*?\/>/,100// formatting is kept in caption,101/Caption with.*<w:bCs.*formatted.*text, like.*<w:rStyle w:val="VerbatimChar".*function_name\(\)/,102]),103]);104105const crossRefInput = docs("crossrefs/callouts.qmd");106const crossRefOutput = outputForInput(crossRefInput, "latex");107testRender(crossRefInput, "latex", true, [108ensureFileRegexMatches(crossRefOutput.outputPath, [109// callout environments are created110/\\begin\{figure\}\[H\]/,111]),112]);113114115