diff options
| author | Joe Mou <dev@mou.fo> | 2026-09-03 01:26:44 -0400 |
|---|---|---|
| committer | Joe Mou <dev@mou.fo> | 2026-09-03 01:27:35 -0400 |
| commit | 80be2418ff2615b454c5edf2819861f58eecf271 (patch) | |
| tree | 97f22f9f6c757eba55921b8827d7dc4b2e9c0a5b /src/app.test.ts | |
| parent | 0c459447b1c12e9de57f0a4e1ab3d25737cf70e8 (diff) | |
Anchor blob lines so #L fragments work
Wrap each rendered line in a <span id="Ln">, for both syntax-highlighted
and plain-text blobs, and shade the line a fragment targets.
Diffstat (limited to 'src/app.test.ts')
| -rw-r--r-- | src/app.test.ts | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/app.test.ts b/src/app.test.ts index 3ecebd0..265465e 100644 --- a/src/app.test.ts +++ b/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: ['<span class="pl-k">const</span> x;', "x++;"], + }); + + assert.match( + html, + /<code><span id="L1"><span class="pl-k">const<\/span> x;<\/span>\n<span id="L2">x\+\+;<\/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, /<code><span id="L1">a < b<\/span>\n<span id="L2">c<\/span><\/code>/); + }); + it("should offer the raw file when there is nothing to display", () => { const html = eta.render("blob.eta", blob); |
