From 501587e256a065816f7eb6007030e728955a32dc Mon Sep 17 00:00:00 2001 From: Joe Mou Date: Thu, 3 Sep 2026 01:26:44 -0400 Subject: Anchor blob lines so #L fragments work Wrap each rendered line in a , for both syntax-highlighted and plain-text blobs, and shade the line a fragment targets. --- cgithub/src/app.test.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'cgithub/src') diff --git a/cgithub/src/app.test.ts b/cgithub/src/app.test.ts index 3ecebd0..265465e 100644 --- a/cgithub/src/app.test.ts +++ b/cgithub/src/app.test.ts @@ -124,6 +124,29 @@ describe("blob view", () => { assert.match(html, /This file cannot be displayed\./); }); + it("should give each syntax-highlighted line an anchor", () => { + const html = eta.render("blob.eta", { + ...blob, + path: "src/app.ts", + htmlLines: ['const x;', "x++;"], + }); + + assert.match( + html, + /const<\/span> x;<\/span>\nx\+\+;<\/span><\/code>/, + ); + }); + + it("should give each plain-text line an anchor", () => { + const html = eta.render("blob.eta", { + ...blob, + path: "notes.txt", + textLines: ["a < b", "c"], + }); + + assert.match(html, /a < b<\/span>\nc<\/span><\/code>/); + }); + it("should offer the raw file when there is nothing to display", () => { const html = eta.render("blob.eta", blob); -- cgit v1.3.1