From 8243f117c913f782895d72b68363417a7cb3dff0 Mon Sep 17 00:00:00 2001 From: DaInfLoop Date: Sun, 28 Jun 2026 12:05:13 +0100 Subject: [PATCH 1/2] feat: add multiline highlighting --- static/script.js | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/static/script.js b/static/script.js index 932139d6..7b2205c1 100644 --- a/static/script.js +++ b/static/script.js @@ -1,25 +1,38 @@ window.addEventListener('DOMContentLoaded', function() { 'use strict'; function highlightHash() { - const selectedRow = document.querySelector('.code .selected'); + const selectedRows = document.querySelectorAll('.code .selected'); - if (selectedRow) { - selectedRow.classList.remove('selected'); + for (const row of selectedRows) { + row.classList.remove('selected'); } - const hash = window.location.hash; + const match = window.location.hash.match(/^#L(\d+)(?:-(\d+))?$/); - if (!hash || !hash.startsWith('#L')) { + if (!match) { return; } - const elem = document.getElementById(hash.substring(1)); + const startRange = match[1]; + const endRange = match[2] ?? startRange; - if (!elem) { + const startElem = document.getElementById(`L${startRange}`); + + if (!startElem) { return; } - elem.parentElement.classList.add('selected'); + startElem.scrollIntoView(); + + let current = startElem; + while (current) { + current.parentElement.classList.add('selected'); + + const line = Number(current.id.substring(1)); + if (line >= endRange) break; + + current = current.parentElement.nextElementSibling.children[0] + } } highlightHash(); From f525cf6908db3b162396c95b52c6cca97e7fb597 Mon Sep 17 00:00:00 2001 From: DaInfLoop Date: Sun, 28 Jun 2026 12:38:01 +0100 Subject: [PATCH 2/2] fix: still render highlight if the hyphen is accidentally kept in `L-` --- static/script.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/static/script.js b/static/script.js index 7b2205c1..4a644e08 100644 --- a/static/script.js +++ b/static/script.js @@ -7,14 +7,14 @@ window.addEventListener('DOMContentLoaded', function() { row.classList.remove('selected'); } - const match = window.location.hash.match(/^#L(\d+)(?:-(\d+))?$/); + const match = window.location.hash.match(/^#L(\d+)(?:-(\d*))?$/); if (!match) { return; } const startRange = match[1]; - const endRange = match[2] ?? startRange; + const endRange = match[2] || startRange; const startElem = document.getElementById(`L${startRange}`);