From e04d65ca2f1b82bdd5ec037e6340df05833b3613 Mon Sep 17 00:00:00 2001 From: gl0w Date: Thu, 10 Sep 2026 07:09:44 +0100 Subject: [PATCH] m6/diff-colors: tokyo night diff classes dark+light (153 tests) --- src/commits.rs | 78 +++++++++++++++++++++++++++++++-- src/forge.rs | 49 ++++++++++++++++++++- src/layout.rs | 117 ++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 237 insertions(+), 7 deletions(-) diff --git a/src/commits.rs b/src/commits.rs index 3467d9f..9c3b288 100644 --- a/src/commits.rs +++ b/src/commits.rs @@ -1,14 +1,15 @@ //! `commits.html` + `commit/.html` (m2, f0rge issue #5). //! -//! Commit subjects, messages, and diffs are untrusted: everything goes -//! through [`crate::layout::esc`] into an escaped `
`. Diffs come from
+//! Commit subjects and messages go through [`crate::layout::esc`]; diffs go
+//! through [`crate::layout::diff_html`] (escaped line-level color spans in an
+//! escaped `
`, m6 diff-colors f0rge #22). Diffs come from
 //! [`crate::gitx::diff`] (binary content noted, output truncated past
 //! 2000 lines with a marker). Nothing here goes through markdown.
 
 use std::path::Path;
 
 use crate::gitx;
-use crate::layout::{esc, page_site};
+use crate::layout::{diff_html, esc, page_site};
 
 /// Short display form of a full sha (first 7 hex chars, git-style).
 #[must_use]
@@ -72,7 +73,7 @@ pub fn render_loaded(
             esc(&c.author),
             esc(&c.date),
             esc(&message),
-            esc(&diff),
+            diff_html(&diff),
         );
         let html = page_site(
             &format!("commit {} — {site_name}", short_sha(&c.sha)),
@@ -237,6 +238,75 @@ mod tests {
         );
     }
 
+    #[test]
+    fn diff_lines_carry_color_spans() {
+        // m6 diff-colors (f0rge #22): hunk cyan, +++/--- bold, + green, - red.
+        let repo = fixture_repo();
+        let out = mktemp("out");
+        render(&repo, &out, "main", 100, "test", "