Skip to content

Commit

Permalink
also fragment <ol>, and make sure the next fragment starts with the c…
Browse files Browse the repository at this point in the history
…orrect number via the `start` attribute
  • Loading branch information
yihui committed Oct 23, 2024
1 parent 58a416f commit 58f0b5e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion js/pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,15 @@
}
const prev = el2.previousElementSibling;
// keep moving el's first item to el2 until page height > H
if (['UL', 'BLOCKQUOTE'].includes(tag) && nChild(el) > 1) while (true) {
if (['UL', 'OL', 'BLOCKQUOTE'].includes(tag) && nChild(el) > 1) while (true) {
const item = el.firstChild;
if (!item) break;
el2.append(item);
if (box_cur.scrollHeight > H) {
// move item back to el if the clone el2 is not the only element on page or has more than one child
(prev || nChild(el2) > 1) && el.insertBefore(item, el.firstChild);
// update the start number of <ol> on next page
tag === 'OL' && (el.start += nChild(el2));
break;
}
}
Expand Down

0 comments on commit 58f0b5e

Please sign in to comment.