aboutsummaryrefslogtreecommitdiff
path: root/views/blob.eta
diff options
context:
space:
mode:
authorJoe Mou <dev@mou.fo>2026-09-03 01:26:44 -0400
committerJoe Mou <dev@mou.fo>2026-09-03 01:27:35 -0400
commit80be2418ff2615b454c5edf2819861f58eecf271 (patch)
tree97f22f9f6c757eba55921b8827d7dc4b2e9c0a5b /views/blob.eta
parent0c459447b1c12e9de57f0a4e1ab3d25737cf70e8 (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 'views/blob.eta')
-rw-r--r--views/blob.eta6
1 files changed, 4 insertions, 2 deletions
diff --git a/views/blob.eta b/views/blob.eta
index 444508e..be9a57e 100644
--- a/views/blob.eta
+++ b/views/blob.eta
@@ -22,9 +22,11 @@
<% } else if (it.htmlContent) { %>
<div class="box"><%~ it.htmlContent %></div>
<% } else if (it.htmlLines) { %>
- <pre class="box"><code><%~ it.htmlLines.join("\n") %></code></pre>
+ <pre class="box"><code><% for (const [i, line] of it.htmlLines.entries()) {
+ %><%= i ? "\n" : "" %><span id="L<%= i + 1 %>"><%~ line %></span><% } %></code></pre>
<% } else if (it.textLines) { %>
- <pre class="box"><code><%= it.textLines.join("\n") %></code></pre>
+ <pre class="box"><code><% for (const [i, line] of it.textLines.entries()) {
+ %><%= i ? "\n" : "" %><span id="L<%= i + 1 %>"><%= line %></span><% } %></code></pre>
<% } else { %>
<div class="box">This file cannot be displayed.</div>
<% } %>