Skip to content

Commit 2e4dd7f

Browse files
authored
fix(html): fix ordered-list numbering (#383)
1 parent b5bbad4 commit 2e4dd7f

File tree

1 file changed

+34
-7
lines changed

1 file changed

+34
-7
lines changed

ebook/en/export/101-linux-commands.html

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -385,16 +385,12 @@
385385
font-size: 0.7rem;
386386
}
387387

388-
.content-wrapper ol {
389-
counter-reset: list-counter;
390-
}
391388

392-
.content-wrapper ol li {
393-
counter-increment: list-counter;
389+
.content-wrapper ol li::before {
390+
display: none;
394391
}
395392

396-
.content-wrapper ol li::before {
397-
content: counter(list-counter);
393+
.content-wrapper .list-badge {
398394
position: absolute;
399395
left: 0.5rem;
400396
top: 50%;
@@ -13571,6 +13567,7 @@ <h2>Download Other Formats</h2>
1357113567
loadPreferences();
1357213568
setupEventListeners();
1357313569
updateActiveNavigation();
13570+
injectOrderedListBadges();
1357413571

1357513572
if (window.innerWidth > 1024) {
1357613573
toggleSidebar();
@@ -13831,6 +13828,36 @@ <h2>Download Other Formats</h2>
1383113828
}
1383213829
}
1383313830
});
13831+
13832+
// Add numeric badges for ordered lists
13833+
function injectOrderedListBadges() {
13834+
try {
13835+
const content = document.querySelector('.content-wrapper');
13836+
if (!content) return;
13837+
13838+
content.querySelectorAll('ol').forEach(function(ol){
13839+
let start = parseInt(ol.getAttribute('start') || '1', 10);
13840+
if (Number.isNaN(start)) start = 1;
13841+
13842+
Array.from(ol.children).forEach(function(li, idx){
13843+
if (li.querySelector('.list-badge')) return;
13844+
13845+
const badge = document.createElement('span');
13846+
badge.className = 'list-badge';
13847+
badge.textContent = String(start + idx);
13848+
13849+
if (getComputedStyle(li).position === 'static') {
13850+
li.style.position = 'relative';
13851+
}
13852+
13853+
li.insertBefore(badge, li.firstChild);
13854+
li.style.paddingLeft = '2.2rem';
13855+
});
13856+
});
13857+
} catch (err) {
13858+
console.error('Failed to inject list badges', err);
13859+
}
13860+
}
1383413861
</script>
1383513862
</body>
1383613863
</html>

0 commit comments

Comments
 (0)