@xiee/utils 1.13.70 → 1.13.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/book-litedown.css +17 -0
- package/css/book-litedown.min.css +1 -1
- package/css/book-litedown.min.css.map +1 -1
- package/js/pages.js +137 -114
- package/js/pages.min.js +1 -1
- package/js/pages.min.js.map +1 -1
- package/package.json +1 -1
package/css/book-litedown.css
CHANGED
|
@@ -49,6 +49,23 @@
|
|
|
49
49
|
inset: auto 5px 5px auto;
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
+
&.pagesjs-fragmented {
|
|
53
|
+
&:not(.fragment-first), &:not(.fragment-last) blockquote {
|
|
54
|
+
&::before, &::after {
|
|
55
|
+
display: none;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
&:not(.fragment-first) {
|
|
59
|
+
&, blockquote {
|
|
60
|
+
padding-top: 1px;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
&:not(.fragment-last) {
|
|
64
|
+
&, blockquote {
|
|
65
|
+
padding-bottom: 1px;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
52
69
|
}
|
|
53
70
|
|
|
54
71
|
/* a tale of two buttons */
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
.pagesjs #TOC>ul>li>ul>li>ul>li>ul,.chapter-toc>ul>li>ul>li>ul{display:none}.pagesjs{& #tab\:assets tr>:nth-child(2){display:none}}.epigraph{margin-bottom:4em;padding:5px;position:relative;&,& blockquote{border:1px solid}&:before,&:after,& blockquote:before,& blockquote:after{content:"•";text-align:center;border:1px solid;width:1em;height:1em;line-height:1;display:inline-block;position:absolute}&:before{left:5px}&:after{content:"❀";color:#639;text-align:right;opacity:.2;border:none;font-size:3em;inset:5px 5px auto auto}& blockquote{padding:1em;&:before{inset:auto auto 5px 5px}&:after{inset:auto 5px 5px auto}}}.new-road{& p{justify-content:center;gap:.5em;display:flex}& button:before{font-size:200%}& .old-knit,& .new-fuse{&:hover:before{content:"❓ "}}& .old-knit{&:before{content:"🧶 "}&:focus:before{content:"😡 "}}& .new-fuse:before{content:"↯ "}& .new-preview:before{content:"⏵ "}& .new-fuse:focus:before{content:"😇 "}}.flex-col{justify-content:space-between;gap:.5em;display:flex;& *{flex:1}& pre:has(code[data-file]){&,&:before{border:groove #f5fffa}& code{border:none;border-top:1px dashed #d3d3d3}&{border-top:none}&:before{border-bottom:none;border-left:none}}}code[data-file]:before{content:attr(data-file);float:right;background:#ffffe0;margin:-1em -1em 1em 1em;padding:.5em;font-size:.9em;display:inline-block}pre:has(code[data-file]){&:before{content:"Output";text-transform:uppercase;border-bottom:none;padding:.5em 1em;font-weight:700;display:inline-block}&:has(code[data-file$=\.Rmd]):before{content:"♧ Example"}&:has(code[data-source]):before{content:"♧ Source"}&.pagesjs-fragmented:first-child{&:before,& code:before{content:unset}}& code,&:before{border:groove #f5fffa}&:before{border-bottom:none}}.no-ref-label{& .cross-ref-sec:before{content:""}}.larger{font-size:1.5em}
|
|
1
|
+
.pagesjs #TOC>ul>li>ul>li>ul>li>ul,.chapter-toc>ul>li>ul>li>ul{display:none}.pagesjs{& #tab\:assets tr>:nth-child(2){display:none}}.epigraph{margin-bottom:4em;padding:5px;position:relative;&,& blockquote{border:1px solid}&:before,&:after,& blockquote:before,& blockquote:after{content:"•";text-align:center;border:1px solid;width:1em;height:1em;line-height:1;display:inline-block;position:absolute}&:before{left:5px}&:after{content:"❀";color:#639;text-align:right;opacity:.2;border:none;font-size:3em;inset:5px 5px auto auto}& blockquote{padding:1em;&:before{inset:auto auto 5px 5px}&:after{inset:auto 5px 5px auto}}&.pagesjs-fragmented{&:not(.fragment-first),&:not(.fragment-last) blockquote{&:before,&:after{display:none}}&:not(.fragment-first){&,& blockquote{padding-top:1px}}&:not(.fragment-last){&,& blockquote{padding-bottom:1px}}}}.new-road{& p{justify-content:center;gap:.5em;display:flex}& button:before{font-size:200%}& .old-knit,& .new-fuse{&:hover:before{content:"❓ "}}& .old-knit{&:before{content:"🧶 "}&:focus:before{content:"😡 "}}& .new-fuse:before{content:"↯ "}& .new-preview:before{content:"⏵ "}& .new-fuse:focus:before{content:"😇 "}}.flex-col{justify-content:space-between;gap:.5em;display:flex;& *{flex:1}& pre:has(code[data-file]){&,&:before{border:groove #f5fffa}& code{border:none;border-top:1px dashed #d3d3d3}&{border-top:none}&:before{border-bottom:none;border-left:none}}}code[data-file]:before{content:attr(data-file);float:right;background:#ffffe0;margin:-1em -1em 1em 1em;padding:.5em;font-size:.9em;display:inline-block}pre:has(code[data-file]){&:before{content:"Output";text-transform:uppercase;border-bottom:none;padding:.5em 1em;font-weight:700;display:inline-block}&:has(code[data-file$=\.Rmd]):before{content:"♧ Example"}&:has(code[data-source]):before{content:"♧ Source"}&.pagesjs-fragmented:first-child{&:before,& code:before{content:unset}}& code,&:before{border:groove #f5fffa}&:before{border-bottom:none}}.no-ref-label{& .cross-ref-sec:before{content:""}}.larger{font-size:1.5em}
|
|
2
2
|
/*# sourceMappingURL=book-litedown.min.css.map */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"mappings":"AAGA,4EAIA,SACE,8CAKF,0DAIE,gCAGA,mLAUA,kBAGA,+GASA,yBAEE,iCAGA,
|
|
1
|
+
{"version":3,"mappings":"AAGA,4EAIA,SACE,8CAKF,0DAIE,gCAGA,mLAUA,kBAGA,+GASA,yBAEE,iCAGA,iCAIF,qBACE,wDACE,+BAIF,uBACE,gCAIF,sBACE,qCAQN,UACE,iDAKA,+BACA,wBACE,+BAEF,YACE,yBACA,gCAEF,kCACA,qCACA,0CAIF,8DAIE,WAGA,2BACE,iCAGA,iDAIA,kBAGA,+CAOJ,wJAUA,yBACE,4HAQA,2DAGA,qDAGA,iCACE,sCAIF,sCAGA,6BAKF,cACE,oCAKF","sources":["book-litedown.css"],"sourcesContent":["/* CSS for https://yihui.org/litedown/ */\n\n/* hide 4th-level TOC items when printing to PDF and 3rd-level in chapter TOC */\n.pagesjs #TOC > ul > li > ul > li > ul > li > ul, .chapter-toc > ul > li > ul > li > ul {\n display: none;\n}\n\n.pagesjs {\n #tab\\:assets tr > :nth-child(2) {\n display: none;\n }\n}\n\n.epigraph {\n position: relative;\n padding: 5px;\n margin-bottom: 4em;\n &, blockquote {\n border: 1px solid;\n }\n &::before, &::after, blockquote::before, blockquote::after {\n content: \"•\";\n position: absolute;\n border: 1px solid;\n display: inline-block;\n width: 1em;\n height: 1em;\n text-align: center;\n line-height: 1;\n }\n &::before {\n left: 5px;\n }\n &::after {\n content: \"❀\";\n color: rebeccapurple;\n font-size: 3em;\n text-align: right;\n border: none;\n opacity: .2;\n inset: 5px 5px auto auto;\n }\n blockquote {\n padding: 1em;\n &::before {\n inset: auto auto 5px 5px;\n }\n &::after {\n inset: auto 5px 5px auto;\n }\n }\n &.pagesjs-fragmented {\n &:not(.fragment-first), &:not(.fragment-last) blockquote {\n &::before, &::after {\n display: none;\n }\n }\n &:not(.fragment-first) {\n &, blockquote {\n padding-top: 1px;\n }\n }\n &:not(.fragment-last) {\n &, blockquote {\n padding-bottom: 1px;\n }\n }\n }\n}\n\n/* a tale of two buttons */\n.new-road {\n p {\n display: flex;\n justify-content: center;\n gap: .5em;\n }\n button::before { font-size: 200%; }\n .old-knit, .new-fuse {\n &:hover::before { content: \"❓ \"; }\n }\n .old-knit {\n &::before { content: \"🧶 \"; }\n &:focus::before { content: \"😡 \"; }\n }\n .new-fuse::before { content: \"↯ \"; }\n .new-preview::before { content: \"⏵ \"; }\n .new-fuse:focus::before { content: \"😇 \"; }\n}\n\n/* arrange elements in columns */\n.flex-col {\n display: flex;\n justify-content: space-between;\n gap: .5em;\n * {\n flex: 1;\n }\n pre:has(code[data-file]) {\n &, &::before {\n border: groove mintcream;\n }\n code {\n border: none;\n border-top: 1px dashed lightgray;\n }\n & {\n border-top: none;\n }\n &::before {\n border-left: none;\n border-bottom: none;\n }\n }\n}\n\ncode[data-file]::before {\n content: attr(data-file);\n font-size: .9em;\n float: right;\n background: lightyellow;\n display: inline-block;\n padding: .5em;\n margin: -1em -1em 1em 1em;\n}\n\npre:has(code[data-file]) {\n &::before {\n content: \"Output\";\n text-transform: uppercase;\n font-weight: bold;\n display: inline-block;\n padding: .5em 1em;\n border-bottom: none;\n }\n &:has(code[data-file$=\".Rmd\"])::before {\n content: \"♧ Example\";\n }\n &:has(code[data-source])::before {\n content: \"♧ Source\";\n }\n &.pagesjs-fragmented:first-child {\n &::before, code::before {\n content: unset;\n }\n }\n code, &::before {\n border: groove mintcream;\n }\n &::before {\n border-bottom: none;\n }\n}\n\n.no-ref-label {\n .cross-ref-sec:before {\n content: \"\";\n }\n}\n\n.larger { font-size: 1.5em; }\n"],"names":[]}
|
package/js/pages.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
function nChild(el) { return el.childElementCount; }
|
|
7
7
|
|
|
8
8
|
const tpl = d.createElement('div'), book = $$('h1').length > 1, boxes = [],
|
|
9
|
+
fr_tag = ['TABLE', 'UL', 'OL', 'BLOCKQUOTE'],
|
|
9
10
|
fr_cls = 'pagesjs-fragmented', fr_1 = 'fragment-first', fr_2 = 'fragment-last',
|
|
10
11
|
tb = ['top', 'bottom'].map(i => {
|
|
11
12
|
const v = getComputedStyle(d.documentElement).getPropertyValue(`--paper-margin-${i}`);
|
|
@@ -15,20 +16,18 @@
|
|
|
15
16
|
tpl.innerHTML = `<div class="pagesjs-header"></div>
|
|
16
17
|
<div class="pagesjs-body"></div>
|
|
17
18
|
<div class="pagesjs-footer"></div>`;
|
|
18
|
-
let box, box_body, box_cls = [],
|
|
19
|
+
let box, box_body, box_cls = [], H, h_code, l_code = [];
|
|
19
20
|
function newPage(el) {
|
|
20
|
-
const n = boxes.length;
|
|
21
|
-
// finish previous n - 1 boxes
|
|
22
|
-
if (n - box_n > 1) {
|
|
23
|
-
boxes.slice(box_n, n - 1).forEach(finish);
|
|
24
|
-
box_n = n - 1;
|
|
25
|
-
}
|
|
26
21
|
el && !$('.pagesjs-body', el) && el.insertAdjacentHTML('afterbegin', tpl.innerHTML);
|
|
27
22
|
box = el || tpl.cloneNode(true); box_body = box.children[1];
|
|
28
|
-
|
|
23
|
+
box.classList.add(...box_cls);
|
|
29
24
|
boxes.includes(box) || boxes.push(box); // store new pages in boxes
|
|
30
25
|
return box;
|
|
31
26
|
}
|
|
27
|
+
// start the next page and finish current page
|
|
28
|
+
function nextPage(el, callback) {
|
|
29
|
+
const cur = box; cur.after(newPage(el)); callback && callback(); finish(cur);
|
|
30
|
+
}
|
|
32
31
|
// compute page numbers and temporarily remove the box
|
|
33
32
|
function finish(box) {
|
|
34
33
|
const h = box.scrollHeight;
|
|
@@ -38,134 +37,156 @@
|
|
|
38
37
|
}
|
|
39
38
|
box.remove();
|
|
40
39
|
}
|
|
41
|
-
function removeBlank(el
|
|
42
|
-
if (!el) return false;
|
|
43
|
-
const v =
|
|
40
|
+
function removeBlank(el) {
|
|
41
|
+
if (!el || el.tagName === 'BODY') return false;
|
|
42
|
+
const v = el.innerText.trim() === '';
|
|
44
43
|
v && el.remove();
|
|
45
44
|
return v;
|
|
46
45
|
}
|
|
47
46
|
function fill(el) {
|
|
48
47
|
// if the element is already a page, just use it as the box
|
|
49
48
|
if (el.classList.contains('pagesjs-page')) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
box_body.append(...[...el.children].slice(3));
|
|
49
|
+
nextPage(el, () => nChild(el) > 3 && (
|
|
50
|
+
// if current element is not empty, fill its content into the box
|
|
51
|
+
box_body.append(...[...el.children].slice(3)),
|
|
54
52
|
// TODO: should we fragment this page if it's too long?
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
nextPage() // create a new empty page
|
|
54
|
+
));
|
|
57
55
|
} else {
|
|
58
56
|
box_body.append(el);
|
|
59
|
-
if (box.scrollHeight
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (el.tagName === 'PRE') for (let i = boxes.length - 1; i >= n0; i--) {
|
|
64
|
-
removeBlank(boxes[i]) && boxes.splice(i, 1);
|
|
57
|
+
if (box.scrollHeight > H) {
|
|
58
|
+
// temporarily remove el from DOM if it can be fragmented, otherwise
|
|
59
|
+
// simply move it to the next page
|
|
60
|
+
breakable(el) ? (el.remove(), fragment(el)) : nextPage(0, () => box_body.append(el));
|
|
65
61
|
}
|
|
66
|
-
// if el can be fragmented, add class *-last, otherwise remove class (e.g.,
|
|
67
|
-
// current box can't even hold el's first child so move whole el to new box)
|
|
68
|
-
(cls.contains(fr_cls) && el.innerHTML !== h0) ? cls.add(fr_2) :
|
|
69
|
-
[el].concat(...$$(`.${fr_cls}`, el)).forEach(el => el.classList.remove(fr_cls, fr_1));
|
|
70
|
-
l_code = []; // clean up code lines
|
|
71
62
|
}
|
|
72
63
|
}
|
|
73
|
-
function fillCode(el,
|
|
74
|
-
el.innerHTML = l_code.slice(
|
|
64
|
+
function fillCode(el, i) {
|
|
65
|
+
el.innerHTML = l_code.slice(0, i).join('\n');
|
|
66
|
+
}
|
|
67
|
+
function breakable(el) {
|
|
68
|
+
l_code = [];
|
|
69
|
+
const t = el.tagName, c = el.firstElementChild;
|
|
70
|
+
if (fr_tag.includes(t)) return true;
|
|
71
|
+
if (t === 'DIV') {
|
|
72
|
+
const cs = el.children;
|
|
73
|
+
return (cs.length === 1 && fr_tag.includes(c?.tagName)) ||
|
|
74
|
+
[...cs].filter(c => c.tagName === 'TABLE').length;
|
|
75
|
+
}
|
|
76
|
+
if (t !== 'PRE') return false;
|
|
77
|
+
if (c?.tagName !== 'CODE') return false;
|
|
78
|
+
// store all lines in l_code (TODO: ensure complete tags on each line)
|
|
79
|
+
l_code = c.innerHTML.replace(/\n$/, '').split('\n');
|
|
80
|
+
const n_code = l_code.length;
|
|
81
|
+
if (n_code < 2) return false;
|
|
82
|
+
h_code = c.offsetHeight / n_code; // approx line height
|
|
83
|
+
c.innerHTML = ''; // temporarily empty <code>; will use l_code
|
|
84
|
+
return true;
|
|
75
85
|
}
|
|
76
86
|
// break elements that are relatively easy to break (such as <ul>)
|
|
77
|
-
function fragment(el, container, parent
|
|
87
|
+
function fragment(el, container, parent) {
|
|
78
88
|
const tag = el.tagName, cls = el.classList, frag = cls.contains(fr_cls);
|
|
79
|
-
parent
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
if (tag === 'PRE') {
|
|
90
|
-
const code = el.firstElementChild;
|
|
91
|
-
if (code?.tagName == 'CODE') {
|
|
92
|
-
const initial = l_code.length;
|
|
93
|
-
// store all lines in l_code
|
|
94
|
-
if (!initial) l_code = code.innerHTML.split('\n');
|
|
95
|
-
let n_code = l_code.length;
|
|
96
|
-
if (n_code > 1 && l_code[n_code - 1] === '') n_code -= 1; // ignore trailing \n
|
|
97
|
-
if (n_code > 1) {
|
|
98
|
-
if (!initial) h_code = code.offsetHeight / n_code; // approx line height
|
|
99
|
-
code.innerHTML = ''; // temporarily empty <code>; will use l_code
|
|
100
|
-
if (fragment(code, el2, el, box_cur)) {
|
|
101
|
-
// exit if the rest of lines are empty
|
|
102
|
-
if (l_code.join('').trim() === '') {
|
|
103
|
-
el2.before(el); el.innerHTML = el2.innerHTML; el2.remove();
|
|
104
|
-
boxes.pop().remove(); newPage(boxes[boxes.length - 1]); l_code = [];
|
|
105
|
-
}
|
|
106
|
-
if (!l_code.length) return; fragment(el);
|
|
107
|
-
} else {
|
|
108
|
-
// the current page can't hold the block; fragment it on next page
|
|
109
|
-
el2.remove(); [code, el].forEach(el => el.classList.remove(fr_cls, fr_1));
|
|
110
|
-
fragment(el);
|
|
111
|
-
}
|
|
112
|
-
} else fillCode(code, 0);
|
|
89
|
+
parent ? cls.add(fr_cls) : (frag ? cls.remove(fr_1) : cls.add(fr_cls, fr_1));
|
|
90
|
+
const el2 = el.cloneNode(); // shallow clone (wrapper only)
|
|
91
|
+
(container || box_body).append(el2);
|
|
92
|
+
const prev = el2.previousElementSibling;
|
|
93
|
+
function fragChildren(action) {
|
|
94
|
+
for (let item of [...el.children]) {
|
|
95
|
+
el2.append(item);
|
|
96
|
+
if (box.scrollHeight > H) {
|
|
97
|
+
action(item); break;
|
|
98
|
+
}
|
|
113
99
|
}
|
|
114
|
-
return removeBlank(el2);
|
|
115
|
-
} else if (tag === 'DIV' && nChild(el) === 1) {
|
|
116
|
-
fragment(el.firstElementChild, el2, el, box_cur);
|
|
117
100
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
101
|
+
if (tag === 'DIV') {
|
|
102
|
+
// fragment <div>'s children (e.g., #TOC > ul)
|
|
103
|
+
fragChildren(item => {
|
|
104
|
+
// fragment item if it can be further fragmented, otherwise put it back
|
|
105
|
+
el.prepend(item);
|
|
106
|
+
fr_tag.includes(item.tagName) ? fragment(item, el2, el) : nChild(el2) && nextPage();
|
|
107
|
+
});
|
|
108
|
+
} else if (tag === 'PRE') {
|
|
109
|
+
fragment(el.firstElementChild, el2, el);
|
|
110
|
+
} else if (tag === 'CODE') {
|
|
111
|
+
// split lines in <code> and try to move as many lines into el2 as possible
|
|
112
|
+
const i = splitCode(el2);
|
|
113
|
+
// i == 0 means not enough space to split code on current page
|
|
114
|
+
fillCode(el2, i); l_code.splice(0, i);
|
|
115
|
+
if (i > 0) {
|
|
116
|
+
l_code.join('').trim() === '' ? (l_code = []) : nextPage();
|
|
117
|
+
}
|
|
118
|
+
} else if (tag === 'TABLE') {
|
|
119
|
+
// when el has no rows left and el2 is not empty, clear el
|
|
120
|
+
splitTable(el, el2) ? nextPage() : (el2.innerHTML !== '' && (el.innerHTML = ''));
|
|
121
|
+
} else {
|
|
122
|
+
// keep moving el's first item to el2 until page height > H
|
|
123
|
+
fr_tag.slice(1).includes(tag) && fragChildren(item => {
|
|
127
124
|
// move item back to el if the clone el2 is not the only element on page or has more than one child
|
|
128
|
-
(prev || nChild(el2) > 1) && el.
|
|
125
|
+
(prev || nChild(el2) > 1 || container?.previousElementSibling) && el.prepend(item);
|
|
129
126
|
// update the start number of <ol> on next page
|
|
130
127
|
tag === 'OL' && (el.start += nChild(el2));
|
|
131
|
-
|
|
128
|
+
// don't open new page if el2 is empty (will open one below when testing el2_empty)
|
|
129
|
+
nChild(el2) && nextPage();
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
const el_empty = !l_code.length && removeBlank(el), el2_empty = removeBlank(el2);
|
|
133
|
+
// add/remove the fragment-* class and exit if el has become empty
|
|
134
|
+
if (el_empty) {
|
|
135
|
+
const cls2 = el2.classList;
|
|
136
|
+
if (parent) {
|
|
137
|
+
container.classList.contains(fr_1) && cls2.remove(fr_cls);
|
|
138
|
+
} else {
|
|
139
|
+
cls2.contains(fr_1) ? cls2.remove(fr_cls, fr_1) : cls2.add(fr_2);
|
|
132
140
|
}
|
|
141
|
+
return;
|
|
133
142
|
}
|
|
134
|
-
//
|
|
135
|
-
if (
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
// if a solution has been tried, shorten step and (in/de)crement by 1
|
|
155
|
-
i = sols.includes(i3) ? i + (delta > 0 ? 1 : -1) : i3;
|
|
156
|
-
(delta > 0 && i >= n) && (i2 = n + 1, i = n); // solution may be n
|
|
143
|
+
// if el2 is empty, it means nothing in el fits the box; we have to start a new box
|
|
144
|
+
if (el2_empty) {
|
|
145
|
+
cls.remove(fr_cls, fr_1); parent || nextPage();
|
|
146
|
+
}
|
|
147
|
+
// keep fragmenting the remaining top-level el when el2 is not empty or not first element
|
|
148
|
+
if ((!el2_empty || prev) && !parent) fragment(el);
|
|
149
|
+
}
|
|
150
|
+
// split table rows
|
|
151
|
+
function splitTable(el, el2) {
|
|
152
|
+
const tb = el.tBodies[0], tb2 = tb.cloneNode(), rows = [...tb.rows], th = el.tHead;
|
|
153
|
+
el2.append(tb2);
|
|
154
|
+
// copy table header and footer
|
|
155
|
+
[th, el.tFoot].forEach(t => t && el2.append(t.cloneNode(true)));
|
|
156
|
+
for (let i = 0; i < rows.length; i++) {
|
|
157
|
+
const row = rows[i];
|
|
158
|
+
tb2.append(row);
|
|
159
|
+
if (box.offsetHeight > H) {
|
|
160
|
+
// clear the clone if current page can't fit even one row
|
|
161
|
+
tb.prepend(row); if (i === 0) el2.innerHTML = '';
|
|
162
|
+
break;
|
|
157
163
|
}
|
|
158
|
-
|
|
159
|
-
|
|
164
|
+
}
|
|
165
|
+
return tb.rows.length;
|
|
166
|
+
}
|
|
167
|
+
// figure out how many lines can fit the box via bisection
|
|
168
|
+
function splitCode(el) {
|
|
169
|
+
let i = i1 = 1, n = l_code.length, i2 = n + 2;
|
|
170
|
+
const sols = []; // solutions tried
|
|
171
|
+
while (i2 > i1 + 1) {
|
|
172
|
+
fillCode(el, i);
|
|
173
|
+
const delta = H - box.offsetHeight;
|
|
174
|
+
if (delta === 0) return i;
|
|
175
|
+
if (delta < 0) {
|
|
176
|
+
if (i <= 1) return 0;
|
|
177
|
+
i2 = i;
|
|
160
178
|
} else {
|
|
161
|
-
|
|
179
|
+
if (i >= n) return i;
|
|
180
|
+
i1 = i;
|
|
162
181
|
}
|
|
163
|
-
|
|
182
|
+
sols.push(i);
|
|
183
|
+
// estimate the number of (more or less) lines needed
|
|
184
|
+
const i3 = i + Math.round(delta / h_code);
|
|
185
|
+
// if a solution has been tried, shorten step and (in/de)crement by 1
|
|
186
|
+
i = sols.includes(i3) ? i + (delta > 0 ? 1 : -1) : i3;
|
|
187
|
+
(delta > 0 && i >= n) && (i2 = n + 2, i = n); // solution may be n
|
|
164
188
|
}
|
|
165
|
-
|
|
166
|
-
el2_empty && cls.remove(fr_cls, fr_1);
|
|
167
|
-
// if the clone is empty, remove it, otherwise keep fragmenting the remaining el
|
|
168
|
-
if (!el2_empty || prev) fragment(container ? parent : el);
|
|
189
|
+
return i1;
|
|
169
190
|
}
|
|
170
191
|
|
|
171
192
|
// use data-short-title of a header if exists, and fall back to inner text
|
|
@@ -222,24 +243,26 @@
|
|
|
222
243
|
a.dataset.pageNumber = '000'; // placeholder for page numbers
|
|
223
244
|
});
|
|
224
245
|
|
|
246
|
+
// temporarily move all elements out of DOM (to speed up rendering single pages)
|
|
225
247
|
const els = [];
|
|
226
248
|
$$('.body').forEach(el => {
|
|
227
|
-
|
|
249
|
+
// move <style> into <head> so it can be applied regardless of its presence in <body>
|
|
250
|
+
const ch = [...el.children].filter(el => el.tagName !== 'STYLE' || d.head.append(el));
|
|
228
251
|
els.push(ch); ch.forEach(el => el.remove());
|
|
229
252
|
});
|
|
230
253
|
// iteratively add elements to pages
|
|
231
254
|
$$('.frontmatter, .abstract, #TOC:not(.chapter-toc)').forEach(el => {
|
|
232
|
-
(fill(el), book &&
|
|
255
|
+
(fill(el), book && nextPage());
|
|
233
256
|
});
|
|
234
257
|
$$('.body').forEach((el, i) => {
|
|
235
258
|
// preserve book chapter classes if exist
|
|
236
259
|
box_cls = ['chapter', 'appendix'].filter(i => el.classList.contains(i));
|
|
237
|
-
book && (box.innerText === '' ? newPage(box) :
|
|
260
|
+
book && (box.innerText === '' ? newPage(box) : nextPage());
|
|
238
261
|
els[i].forEach(fill);
|
|
239
262
|
// clean up container and self if empty
|
|
240
263
|
removeBlank(el.parentNode); removeBlank(el);
|
|
241
264
|
});
|
|
242
|
-
|
|
265
|
+
finish(box); // finish the last box
|
|
243
266
|
cls.remove('pagesjs-filling');
|
|
244
267
|
|
|
245
268
|
// add page number, title, etc. to data-* attributes of page elements
|
package/js/pages.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(e=>{function t(t,n=e){return n?.querySelector(t)}function
|
|
1
|
+
(e=>{function t(t,n=e){return n?.querySelector(t)}function n(t,n=e){return n?n.querySelectorAll(t):[]}function s(e){return e.childElementCount}const r=e.createElement("div"),a=n("h1").length>1,i=[],o=["TABLE","UL","OL","BLOCKQUOTE"],c="pagesjs-fragmented",l="fragment-first",d=["top","bottom"].map((t=>+getComputedStyle(e.documentElement).getPropertyValue(`--paper-margin-${t}`).replace("px","")||0));r.className="pagesjs-page",r.innerHTML='<div class="pagesjs-header"></div>\n<div class="pagesjs-body"></div>\n<div class="pagesjs-footer"></div>';let f,p,g,u,h=[],m=[];function E(e){return e&&!t(".pagesjs-body",e)&&e.insertAdjacentHTML("afterbegin",r.innerHTML),f=e||r.cloneNode(!0),p=f.children[1],f.classList.add(...h),i.includes(f)||i.push(f),f}function L(e,t){const n=f;n.after(E(e)),t&&t(),b(n)}function b(e){const t=e.scrollHeight;if(t>g&&!e.dataset.pagesOffset){const s=function(e,t){let s=+e.dataset.pagesOffset;if(s)return s;if(s=Math.ceil(t/g),s<=1)return s;const r=d.concat([...n("thead",e)].map((e=>+e.offsetHeight))).reduce(((e,t)=>e+t));if(!r)return s;function a(){return Math.ceil((t+(s-1)*r)/g)}let i=a();for(;i>s;)s=i,i=a();return s}(e,t);s>1&&(e.dataset.pagesOffset=s)}e.remove()}function T(e){if(!e||"BODY"===e.tagName)return!1;const t=""===e.innerText.trim();return t&&e.remove(),t}function v(e){e.classList.contains("pagesjs-page")?L(e,(()=>s(e)>3&&(p.append(...[...e.children].slice(3)),L()))):(p.append(e),f.scrollHeight>g&&(!function(e){m=[];const t=e.tagName,n=e.firstElementChild;if(o.includes(t))return!0;if("DIV"===t){const t=e.children;return 1===t.length&&o.includes(n?.tagName)||[...t].filter((e=>"TABLE"===e.tagName)).length}if("PRE"!==t)return!1;if("CODE"!==n?.tagName)return!1;m=n.innerHTML.replace(/\n$/,"").split("\n");const s=m.length;return!(s<2)&&(u=n.offsetHeight/s,n.innerHTML="",!0)}(e)?L(0,(()=>p.append(e))):(e.remove(),H(e))))}function j(e,t){e.innerHTML=m.slice(0,t).join("\n")}function H(e,t,n){const r=e.tagName,a=e.classList,i=a.contains(c);n?a.add(c):i?a.remove(l):a.add(c,l);const d=e.cloneNode();(t||p).append(d);const h=d.previousElementSibling;function E(t){for(let n of[...e.children])if(d.append(n),f.scrollHeight>g){t(n);break}}if("DIV"===r)E((t=>{e.prepend(t),o.includes(t.tagName)?H(t,d,e):s(d)&&L()}));else if("PRE"===r)H(e.firstElementChild,d,e);else if("CODE"===r){const e=function(e){let t=i1=1,n=m.length,s=n+2;const r=[];for(;s>i1+1;){j(e,t);const a=g-f.offsetHeight;if(0===a)return t;if(a<0){if(t<=1)return 0;s=t}else{if(t>=n)return t;i1=t}r.push(t);const i=t+Math.round(a/u);t=r.includes(i)?t+(a>0?1:-1):i,a>0&&t>=n&&(s=n+2,t=n)}return i1}(d);j(d,e),m.splice(0,e),e>0&&(""===m.join("").trim()?m=[]:L())}else"TABLE"===r?!function(e,t){const n=e.tBodies[0],s=n.cloneNode(),r=[...n.rows],a=e.tHead;t.append(s),[a,e.tFoot].forEach((e=>e&&t.append(e.cloneNode(!0))));for(let e=0;e<r.length;e++){const a=r[e];if(s.append(a),f.offsetHeight>g){n.prepend(a),0===e&&(t.innerHTML="");break}}return n.rows.length}(e,d)?""!==d.innerHTML&&(e.innerHTML=""):L():o.slice(1).includes(r)&&E((n=>{(h||s(d)>1||t?.previousElementSibling)&&e.prepend(n),"OL"===r&&(e.start+=s(d)),s(d)&&L()}));const b=!m.length&&T(e),v=T(d);if(b){const e=d.classList;n?t.classList.contains(l)&&e.remove(c):e.contains(l)?e.remove(c,l):e.add("fragment-last")}else v&&(a.remove(c,l),n||L()),v&&!h||n||H(e)}function N(e){return e&&(e.dataset.shortTitle||e.innerText)}const O=N(t("h1.title, .frontmatter h1, .title, h1")),y=(a?"h1":"h2")+":not(.frontmatter *)";function C(){if("complete"!==e.readyState)return setTimeout(C,10);const s=e.body.classList;if(s.contains("pagesjs"))return;s.add("pagesjs"),e.body.insertAdjacentElement("afterbegin",E()),g=f.clientHeight||window.innerHeight,n(":is(#TOC, .footnotes, .chapter-before, .chapter-after):is(.side-left, .side-right).side").forEach((e=>{e.classList.remove("side","side-left","side-right")})),s.add("pagesjs-filling"),n('#TOC a[href^="#"]').forEach((t=>{const n=e.createElement("span"),s=t.firstElementChild;for(s?.classList.contains("section-number")?s.after(n):t.insertAdjacentElement("afterbegin",n);n.nextSibling;)n.append(n.nextSibling);t.insertAdjacentHTML("beforeend",'<span class="dot-leader"></span>'),t.dataset.pageNumber="000"}));const r=[];n(".body").forEach((t=>{const n=[...t.children].filter((t=>"STYLE"!==t.tagName||e.head.append(t)));r.push(n),n.forEach((e=>e.remove()))})),n(".frontmatter, .abstract, #TOC:not(.chapter-toc)").forEach((e=>{v(e),a&&L()})),n(".body").forEach(((e,t)=>{h=["chapter","appendix"].filter((t=>e.classList.contains(t))),a&&(""===f.innerText?E(f):L()),r[t].forEach(v),T(e.parentNode),T(e)})),b(f),s.remove("pagesjs-filling");let o,c=0;i.forEach((e=>{if(a){if(t(".frontmatter",e))return;t(y,e)&&(o="")}const s=+e.dataset.pagesOffset||1;s>1&&e.classList.add("page-multiple"),c+=s,e.classList.add("page-"+(c%2==0?"even":"odd"));const r={pageNumber:c,mainTitle:O,pageTitle:o};let i;[e.children[0],e.children[2]].forEach((e=>{for(const t in r)r[t]&&(e.dataset[t]=r[t])})),o=N([...n(y,e)].pop())||o,n(".footnotes",e).forEach(((t,n)=>{0===n?(i=t,e.children[1].after(t)):(i.append(...t.children),t.remove())}))})),e.body.prepend(...i),n('#TOC a[href^="#"]').forEach((e=>{const n=t(`.pagesjs-page:has(#${CSS.escape(e.getAttribute("href").replace(/^#/,""))}) .pagesjs-header`);e.dataset.pageNumber=n?n.dataset.pageNumber:""}))}addEventListener("beforeprint",C);let M=sessionStorage.getItem("pagesjs");M&&C(),addEventListener("keypress",(e=>"p"===e.key&&(C(),M=M?"":"1",sessionStorage.setItem("pagesjs",M),M||location.reload())))})(document);
|
|
2
2
|
//# sourceMappingURL=pages.min.js.map
|
package/js/pages.min.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["d","$","s","el","querySelector","$$","querySelectorAll","nChild","childElementCount","tpl","createElement","book","length","boxes","fr_cls","fr_1","tb","map","i","getComputedStyle","documentElement","getPropertyValue","replace","className","innerHTML","box","box_body","H","h_code","box_cls","
|
|
1
|
+
{"version":3,"names":["d","$","s","el","querySelector","$$","querySelectorAll","nChild","childElementCount","tpl","createElement","book","length","boxes","fr_tag","fr_cls","fr_1","tb","map","i","getComputedStyle","documentElement","getPropertyValue","replace","className","innerHTML","box","box_body","H","h_code","box_cls","l_code","newPage","insertAdjacentHTML","cloneNode","children","classList","add","includes","push","nextPage","callback","cur","after","finish","h","scrollHeight","dataset","pagesOffset","n","Math","ceil","m","concat","offsetHeight","reduce","m1","m2","newPages","n2","calcPages","remove","removeBlank","tagName","v","innerText","trim","fill","contains","append","slice","t","c","firstElementChild","cs","filter","split","n_code","breakable","fragment","fillCode","join","container","parent","tag","cls","frag","el2","prev","previousElementSibling","fragChildren","action","item","prepend","i1","i2","sols","delta","i3","round","splitCode","splice","tBodies","tb2","rows","th","tHead","tFoot","forEach","row","splitTable","start","el_empty","el2_empty","cls2","shortTitle","main","ps","paginate","readyState","setTimeout","body","insertAdjacentElement","clientHeight","window","innerHeight","a","nextSibling","pageNumber","els","ch","head","parentNode","page_title","N","info","mainTitle","pageTitle","ft","key","pop","p","CSS","escape","getAttribute","addEventListener","pg","sessionStorage","getItem","e","setItem","location","reload","document"],"sources":["pages.js"],"mappings":"AAEA,CAACA,IACC,SAAUC,EAAEC,EAAGC,EAAKH,GAAK,OAAOG,GAAIC,cAAcF,EAAI,CACtD,SAASG,EAAGH,EAAGC,EAAKH,GAAK,OAAOG,EAAKA,EAAGG,iBAAiBJ,GAAK,EAAI,CAClE,SAASK,EAAOJ,GAAM,OAAOA,EAAGK,iBAAmB,CAEnD,MAAMC,EAAMT,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