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