MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / render_html

Function render_html

atomic-cli/src/commands/triage/output.rs:300–417  ·  view source on GitHub ↗

Render the report as ONE self-contained HTML document. No external URLs, CDNs, or scripts: all CSS is inline and the only JavaScript is a tiny vanilla filter function. Every interpolated string is HTML-escaped (via [`html_escape`]); the embedded report JSON is `<`/`>`/`&`-escaped so it cannot break out of its ` ` container.

(report: &TriageReport)

Source from the content-addressed store, hash-verified

298/// (via [`html_escape`]); the embedded report JSON is `<`/`>`/`&`-escaped so it
299/// cannot break out of its `<script>` container.
300pub fn render_html(report: &TriageReport) -> String {
301 let verdict_class = match report.verdict {
302 Verdict::Blocked => "blocked",
303 Verdict::Stale => "stale",
304 Verdict::Ready => "ready",
305 };
306 let verdict_label = match report.verdict {
307 Verdict::Blocked => "BLOCKED",
308 Verdict::Stale => "STALE",
309 Verdict::Ready => "READY",
310 };
311 let merkle_short: String = report.inputs.view_merkle.chars().take(8).collect();
312
313 let mut h = String::new();
314 h.push_str("<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n");
315 h.push_str("<meta charset=\"utf-8\">\n");
316 h.push_str("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n");
317 h.push_str(&format!(
318 "<title>Triage {} \u{2192} {}</title>\n",
319 html_escape(&report.inputs.feature),
320 html_escape(&report.inputs.target)
321 ));
322 h.push_str("<style>\n");
323 h.push_str(HTML_STYLE);
324 h.push_str("\n</style>\n</head>\n<body>\n");
325
326 // Verdict banner.
327 h.push_str(&format!("<header class=\"banner {verdict_class}\">\n"));
328 h.push_str(&format!(
329 "<div class=\"verdict\">{}</div>\n",
330 html_escape(verdict_label)
331 ));
332 h.push_str(&format!(
333 "<div class=\"route\">{} \u{2192} {}</div>\n",
334 html_escape(&report.inputs.feature),
335 html_escape(&report.inputs.target)
336 ));
337 h.push_str(&format!(
338 "<div class=\"merkle\">merkle {}</div>\n",
339 html_escape(&merkle_short)
340 ));
341 let s = &report.summary;
342 h.push_str(&format!(
343 "<div class=\"counts\">{} changes \u{00b7} {} files \u{00b7} criteria {} met / {} unmet \u{00b7} findings {} block / {} warn / {} info</div>\n",
344 s.changes, s.files, s.criteria_met, s.criteria_unmet, s.findings_block, s.findings_warn, s.findings_info
345 ));
346 h.push_str(&format!(
347 "<div class=\"ref\">{}</div>\n",
348 html_escape(&report.reference)
349 ));
350 h.push_str("</header>\n");
351
352 // Findings.
353 h.push_str("<section id=\"findings\">\n<h2>Findings</h2>\n");
354 h.push_str("<div class=\"filters\">\n");
355 for (label, key) in [
356 ("All", "all"),
357 ("Block", "block"),

Calls 7

render_finding_cardFunction · 0.85
render_walkthroughFunction · 0.85
render_intentFunction · 0.85
render_changeFunction · 0.85
escape_script_jsonFunction · 0.85
collectMethod · 0.45
is_emptyMethod · 0.45