SPB Git forge

spb/spbgit

Public MIT ★ Pinned

SPB Git — the platform hosting itself

15commits 1branches 1releases
833.0 KBsize
maindefault branch
17 days agolast push
JavaScript 67.4% CSS 16.7% Nunjucks 13.7% Shell 2.3%

fix: doubled line spacing in blob view (strip newlines between block line spans)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Simon-Pierre Boucher committed 1 mo ago (Aug 10, 2026) parent af5f588

1 changed file +6 −1

modified src/render/highlight.mjs +6 −1
@@ -159,10 +159,15 @@ export async function highlightFile(code, path) {
159 159 const lang = FILENAME_TO_LANG[base] ?? EXT_TO_LANG[ext] ?? null;
160 160 const html = await highlight(code, lang);
161 161 let line = 0;
162 − const withAnchors = html.replaceAll('<span class="line">', () => {
162 + let withAnchors = html.replaceAll('<span class="line">', () => {
163 163 line += 1;
164 164 return `<span class="line" id="L${line}"><a class="ln" href="#L${line}" aria-label="Line ${line}">${line}</a>`;
165 165 });
166 + // Lines render as display:block — the \n shiki leaves between spans would
167 + // otherwise add a phantom empty line inside the <pre> (doubled spacing).
168 + withAnchors = withAnchors
169 + .replace(/\n(?=<span class="line")/g, '')
170 + .replace(/\n(?=<\/code>)/g, '');
166 171 const lines = code === '' ? 0 : code.split('\n').length;
167 172 return { html: withAnchors, lines, lang };
168 173 }
169 174