SPB Git

spb/spbgit Public MIT

SPB Git — the platform hosting itself

JavaScript 73.9% CSS 11.7% Nunjucks 11.6% Shell 2.7%

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 7 h ago (Aug 10, 2026) parent af5f588

Showing 1 changed file with +6 and −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