From e156259e2eac2767399ff2314debbe6be2d92580 Mon Sep 17 00:00:00 2001 From: Daniel Fry Date: Wed, 1 Jul 2026 20:42:24 +0100 Subject: [PATCH] fix(fidelity): escape Markdown/Vue hazards in generated report cells MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The fidelity report is rendered by VitePress, which parses Markdown as Vue. A known-difference description contained a bare ``, which VitePress read as an unclosed HTML element — breaking `vitepress build` (and the Pages deploy) since the report began publishing that row. Escape free-text table cells in the generator (angle brackets, pipes, and {{ }} interpolation) so corpus-derived text can't break the page. Applies to probe reasons and known-difference rows. The one currently-affected cell () is updated in the committed page to match the fixed generator's deterministic output, keeping the drift check green. --- .../vitest-native/scripts/fidelity-report.mjs | 17 +++++++++++++++-- website/guide/fidelity.md | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/packages/vitest-native/scripts/fidelity-report.mjs b/packages/vitest-native/scripts/fidelity-report.mjs index e424ff5..4fc0232 100644 --- a/packages/vitest-native/scripts/fidelity-report.mjs +++ b/packages/vitest-native/scripts/fidelity-report.mjs @@ -98,12 +98,25 @@ const knownDiffs = fs.existsSync(knownDiffsPath) ? JSON.parse(fs.readFileSync(knownDiffsPath, "utf8")) : []; +// The page is built by VitePress, which parses Markdown as Vue: a bare `` +// in free text is read as an (unclosed) HTML element and breaks the build, `|` +// breaks table columns, and `{{ }}` is Vue interpolation. Probe names/reasons +// and known-difference text come from the corpus, so escape those hazards in +// any cell rendered as free text (not inside a code span). +const cell = (s) => + String(s ?? "") + .replace(/\|/g, "\\|") + .replace(//g, ">") + .replace(/\{\{/g, "{{") + .replace(/\}\}/g, "}}"); + const probeRows = probes - .map((p) => `| \`${p.name}\` | ${p.match ? "✅ match" : `❌ ${p.reason ?? "diverged"}`} |`) + .map((p) => `| \`${p.name}\` | ${p.match ? "✅ match" : `❌ ${cell(p.reason ?? "diverged")}`} |`) .join("\n"); const knownDiffRows = knownDiffs.length - ? knownDiffs.map((d) => `| ${d.area} | ${d.difference} | ${d.why} |`).join("\n") + ? knownDiffs.map((d) => `| ${cell(d.area)} | ${cell(d.difference)} | ${cell(d.why)} |`).join("\n") : "| _none recorded_ | | |"; const page = `