Files

17 lines
561 B
JavaScript
Raw Permalink Normal View History

2025-11-14 17:30:19 +01:00
function wrapTextLinesInSpan(element){
const lines = element.textContent.split('\n').filter(Boolean);
element.textContent = '';
for (let index = 0; index < lines.length; index++) {
const span = document.createElement('span');
span.className = 'line';
span.textContent = lines[index];
element.appendChild(span);
if(index < lines.length - 1){
element.appendChild(document.createTextNode('\n'));
}
}
}
document.querySelectorAll('pre.number-lines').forEach(wrapTextLinesInSpan);