${escapeHtml(code.trim())}`),
);
s = s.replace(/\[([^\]]*)\]\(\s*([^)\s]+)(?:\s+"[^"]*")?\s*\)/g, (_m, label: string, href: string) => {
const shown = emphasis(escapeHtml(label));
if (href.startsWith(CITE_SCHEME)) {
const id = href.slice(CITE_SCHEME.length).trim();
return hold(`${shown}${citeMarker(cite(id), id)}`);
}
const safe = safeHref(href, siteUrl, fragmentBase);
return hold(safe ? `${shown}` : shown);
});
s = s.replace(/<(https?:\/\/[^\s<>]+)>/g, (_m, url: string) => hold(`${escapeHtml(url)}`));
s = emphasis(escapeHtml(s))
.replace(/ {2,}\n/g, "${escapeHtml(body.join("\n"))}`);
continue;
}
const h = HEADING_RE.exec(line);
if (h) {
const level = Math.min(6, base - 1 + h[1].length);
out.push(`${markdownToHtml(inner.join("\n"), cite, opts)}`); continue; } const first = LIST_RE.exec(line); if (first) { const ordered = /\d/.test(first[1]); const items: string[] = []; while (i < lines.length) { const m = LIST_RE.exec(lines[i]); if (m && /\d/.test(m[1]) === ordered) { items.push(m[2]); i++; } else if (items.length > 0 && !isBlank(lines[i]) && /^\s{2,}\S/.test(lines[i])) { items[items.length - 1] += `\n${lines[i++].trim()}`; } else break; } const start = ordered ? Number.parseInt(first[1], 10) : 1; const tag = ordered ? "ol" : "ul"; const attr = ordered && start !== 1 ? ` start="${start}"` : ""; out.push(`<${tag}${attr}>${items.map((it) => `
${inline(para.join("\n").trim())}
`); } return out.join("\n"); } // ─── The stylesheet ─── // Small and self-contained: system fonts, a light page that prints as it // reads. The verdict chip takes its colour from `--v` (the view's verdict // styles, report overrides applied), as the site's VerdictChip does. export const REPORT_EXPORT_CSS = ` :root{--fg:#1b1b1b;--muted:#5d5d5d;--border:#d8d8d8;--surface:#f6f6f4;--accent:#1f4e8c;color-scheme:light} *{box-sizing:border-box} html{-webkit-text-size-adjust:100%} body{margin:0;background:#fff;color:var(--fg);font:16px/1.55 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif} main{max-width:46rem;margin:0 auto;padding:2rem 1rem 3rem} a{color:var(--accent);text-decoration:underline;text-decoration-thickness:1px;text-underline-offset:2px;overflow-wrap:anywhere} h1,h2,h3,h4{line-height:1.25;margin:0} h1{font-size:2rem;font-weight:600;letter-spacing:-.01em;overflow-wrap:anywhere} h1 .series{display:block;color:var(--accent)} h1 .title{display:block;font-weight:400} h2{font-size:1.5rem;font-weight:600;margin-top:2.5rem;padding-top:1rem;border-top:1px solid var(--border)} h3{font-size:1.15rem;font-weight:600} h4,h5,h6{font-size:1rem;font-weight:600;margin:1rem 0 .25rem} p{margin:.6rem 0} q{quotes:"\\201C" "\\201D"} blockquote{margin:.75rem 0;padding-left:.9rem;border-left:3px solid var(--border);color:var(--muted)} code{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:.88em;background:var(--surface);padding:.05em .3em;border-radius:3px} pre{background:var(--surface);padding:.75rem;border-radius:4px;overflow-x:auto} pre code{background:none;padding:0} img{max-width:100%;height:auto} video,audio{display:block;width:100%;max-width:36rem;margin:.5rem 0} .subtitle{font-size:1.15rem;color:var(--muted);margin:.5rem 0 0} .dates{margin:.35rem 0 0;font-family:ui-monospace,SFMono-Regular,Menlo,monospace} .dates a{color:inherit} .dates,.label,.meta,.export-footer{font-size:.85rem;color:var(--muted)} .label{font:600 .7rem/1.2 ui-monospace,SFMono-Regular,Menlo,monospace;text-transform:uppercase;letter-spacing:.14em;margin:1.25rem 0 .4rem} header.report-head{padding-bottom:1.25rem;border-bottom:1px solid var(--border)} .subject{margin:1rem 0 0;padding:.5rem .9rem;border-left:4px solid var(--border);border-radius:0 6px 6px 0;background:var(--surface);overflow-wrap:anywhere} .tier{display:flex;align-items:center;gap:.6rem;margin:2.25rem 0 .5rem} .tier .dots{display:inline-flex;gap:.25rem} .tier .dots i{display:inline-block;width:.4rem;height:.4rem;border-radius:50%;border:1px solid var(--muted)} .tier .dots i.on{background:var(--accent);border-color:var(--accent)} .tier .rule{flex:1;height:1px;background:var(--border)} .tier+h2{margin-top:.5rem;padding-top:0;border-top:0} h2.section{font-size:1.3rem} .jumps{font-size:.92rem} .found h3{margin:1rem 0 .4rem} .found ul{margin:0;padding-left:1.1rem;font-size:.95rem} .found li{margin:.3rem 0} .found li>a{color:var(--fg);font-weight:600;text-decoration:none} .gist{color:var(--muted)} .method{margin:.75rem 0} .flag,.added{display:inline-flex;align-items:center;gap:.35rem;white-space:nowrap} .flag{border:1px solid color-mix(in srgb,var(--accent) 40%,#fff);background:color-mix(in srgb,var(--accent) 8%,#fff);color:var(--accent);border-radius:999px;padding:.05rem .6rem;font-size:.78rem;font-weight:500} .added{opacity:.8;vertical-align:-.1em} .sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap} svg.mark{flex:none;border-radius:22%} details.given{margin:.4rem 0 0} details.given summary{cursor:pointer;font:.8rem/1.4 ui-monospace,SFMono-Regular,Menlo,monospace;color:var(--muted)} .source{padding-left:.75rem;border-left:4px solid var(--border)} .tally{display:flex;flex-wrap:wrap;gap:.4rem;list-style:none;padding:0;margin:.4rem 0 0} .verdict{display:inline-flex;align-items:center;gap:.4rem;border:1px solid var(--v);border-radius:999px;padding:.1rem .65rem;font-size:.8rem;font-weight:600;background:color-mix(in srgb,var(--v) 14%,#fff);white-space:nowrap} .verdict::before{content:"";width:.5rem;height:.5rem;border-radius:50%;background:var(--v)} .verdict .n{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;color:var(--muted);font-weight:400} nav.toc ol{margin:.5rem 0;padding-left:1.4rem} ol.timeline{list-style:none;margin:1rem 0 0;padding:0 0 0 1rem;border-left:2px solid var(--border)} ol.timeline>li{margin:0 0 1.5rem} .entry-date{margin:0;font:600 .95rem/1.3 ui-monospace,SFMono-Regular,Menlo,monospace} .entry-date a{text-decoration:none} .entry-date .meta{font-weight:400} ol.timeline h3{margin:.2rem 0 0} .claim{margin:1.25rem 0;padding:1rem 1.1rem;border:1px solid var(--border);border-radius:8px} .claim-head{display:flex;flex-wrap:wrap;align-items:baseline;gap:.4rem .7rem} .claim-head h3{flex:1 1 15rem} .claim-text{color:var(--muted);font-size:.95rem} figure.sentence{margin:.75rem 0;padding-left:.75rem;border-left:4px solid var(--border)} figure.sentence img{display:block;border:1px solid var(--border);border-radius:4px;background:#fff;break-inside:avoid} figure.sentence figcaption{font-size:.85rem;color:var(--muted);margin-top:.3rem} .evidence{margin:.4rem 0 0;padding-left:1.2rem;font-size:.92rem} .evidence li{margin:.2rem 0} sup.cite{font-size:.72em;line-height:0;margin-left:.1em} sup.cite a{text-decoration:none;font-weight:600} .archives{margin:.3rem 0 0;padding-left:1.2rem;font-size:.85rem} .archives li{margin:.15rem 0} .archives .ctx{color:var(--muted)} .source{margin:1rem 0} ol.references{padding-left:2.2rem} ol.references>li{margin:0 0 1rem;padding-left:.2rem} ol.references .quote{margin:0;font-size:1rem} ol.references .meta,ol.references .links{margin:.15rem 0;font-size:.85rem} ol.references img{display:block;max-width:24rem;border:1px solid var(--border);border-radius:4px;margin:.4rem 0;break-inside:avoid} :target{background:#fff6d6} .export-footer{margin-top:3rem;padding-top:1rem;border-top:1px solid var(--border)} .export-footer p{margin:.25rem 0} @media print{ @page{size:A4;margin:16mm 14mm} body{font-size:11pt} main{max-width:none;padding:0} a{color:var(--fg)} h2{break-after:avoid} .claim{break-inside:auto} :target{background:none} } `.trim(); // ─── The parts ─── function verdictChip(view: ReportPageView, verdict: NonNullable