@xiee/utils 1.13.65 → 1.13.66
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/default.css +1 -1
- package/css/default.min.css +1 -1
- package/css/default.min.css.map +1 -1
- package/css/heading-anchor.css +4 -2
- package/css/heading-anchor.min.css +1 -1
- package/css/heading-anchor.min.css.map +1 -1
- package/js/heading-anchor.js +1 -1
- package/js/heading-anchor.min.js +1 -1
- package/js/heading-anchor.min.js.map +1 -1
- package/js/pages.js +36 -27
- package/js/pages.min.js +1 -1
- package/js/pages.min.js.map +1 -1
- package/package.json +1 -1
package/css/default.css
CHANGED
|
@@ -51,8 +51,8 @@ hr, .footnotes::before { border: 1px dashed #ddd; }
|
|
|
51
51
|
.frontmatter { text-align: center; }
|
|
52
52
|
#TOC {
|
|
53
53
|
a { text-decoration: none; }
|
|
54
|
-
& > ul { padding: 0; }
|
|
55
54
|
ul { list-style: none; padding-left: 1em; }
|
|
55
|
+
& > ul { padding: 0; }
|
|
56
56
|
ul ul { border-left: 1px solid lightsteelblue; }
|
|
57
57
|
}
|
|
58
58
|
table:not([class]), .body h2 { border-bottom: 1px solid #666; }
|
package/css/default.min.css
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
body{max-width:800px;margin:auto;padding:1em;font-family:sans-serif;line-height:1.5}body,.abstract,code,.footnotes,footer,#refs,.caption{font-size:.9em}li li{font-size:.95em}ul:has(li>input[type=checkbox]){padding-left:1em;list-style:none}*,:before,:after{box-sizing:border-box}a{color:#4682b4}pre,img{max-width:100%}pre{white-space:pre-wrap;word-break:break-word}pre code{padding:1em;display:block;overflow-x:auto}code{font-family:DejaVu Sans Mono,Droid Sans Mono,Lucida Console,Consolas,Monaco,monospace}:not(pre)>code,code[class],div>.caption{background-color:#f8f8f8}pre>code:is(:not([class]),.language-plain,.language-none,.plain),.box,.figure,.table{background-color:inherit;border:1px solid #eee}pre>code{&.message{border-color:#9eeaf9}&.warning{background:#fff3cd;border-color:#fff3cd}&.error{background:#f8d7da;border-color:#f8d7da}}.fenced-chunk{border-left:1px solid #666}.code-fence{opacity:.4;border:1px dashed #666;border-left:2px solid;&:hover{opacity:inherit}}.box,.figure,.table{margin:1em auto}div>.caption{padding:1px 1em}.figure{& p:has(img),& pre:has(svg){text-align:center}}.flex-col{justify-content:space-between;display:flex}table :is(th,td){font-variant-numeric:tabular-nums;padding:5px}table:not([class]){border-top:1px solid #666;margin:1em auto;& thead th{border-bottom:1px solid #ddd}}table:not([class]),.table-striped{& thead,& tfoot,& tr:nth-child(2n){background:#f5f5f5}}blockquote{color:#666;border-left:.5em solid #eee;margin:0;padding:1px 1em}hr,.footnotes:before{border:1px dashed #ddd}.frontmatter{text-align:center}#TOC{& a{text-decoration:none}
|
|
1
|
+
body{max-width:800px;margin:auto;padding:1em;font-family:sans-serif;line-height:1.5}body,.abstract,code,.footnotes,footer,#refs,.caption{font-size:.9em}li li{font-size:.95em}ul:has(li>input[type=checkbox]){padding-left:1em;list-style:none}*,:before,:after{box-sizing:border-box}a{color:#4682b4}pre,img{max-width:100%}pre{white-space:pre-wrap;word-break:break-word}pre code{padding:1em;display:block;overflow-x:auto}code{font-family:DejaVu Sans Mono,Droid Sans Mono,Lucida Console,Consolas,Monaco,monospace}:not(pre)>code,code[class],div>.caption{background-color:#f8f8f8}pre>code:is(:not([class]),.language-plain,.language-none,.plain),.box,.figure,.table{background-color:inherit;border:1px solid #eee}pre>code{&.message{border-color:#9eeaf9}&.warning{background:#fff3cd;border-color:#fff3cd}&.error{background:#f8d7da;border-color:#f8d7da}}.fenced-chunk{border-left:1px solid #666}.code-fence{opacity:.4;border:1px dashed #666;border-left:2px solid;&:hover{opacity:inherit}}.box,.figure,.table{margin:1em auto}div>.caption{padding:1px 1em}.figure{& p:has(img),& pre:has(svg){text-align:center}}.flex-col{justify-content:space-between;display:flex}table :is(th,td){font-variant-numeric:tabular-nums;padding:5px}table:not([class]){border-top:1px solid #666;margin:1em auto;& thead th{border-bottom:1px solid #ddd}}table:not([class]),.table-striped{& thead,& tfoot,& tr:nth-child(2n){background:#f5f5f5}}blockquote{color:#666;border-left:.5em solid #eee;margin:0;padding:1px 1em}hr,.footnotes:before{border:1px dashed #ddd}.frontmatter{text-align:center}#TOC{& a{text-decoration:none}& ul{padding-left:1em;list-style:none}&>ul{padding:0}& ul ul{border-left:1px solid #b0c4de}}table:not([class]),.body h2{border-bottom:1px solid #666}.body .appendix,.appendix~h2{border-bottom-style:dashed}.main-number:after{content:"."}span[class^=ref-number-]{font-weight:700}.ref-number-fig:after,.ref-number-tab:after{content:":"}.cross-ref-chp:before{content:"Chapter "}.cross-ref-sec:before{content:"Section "}.cross-ref-fig:before,.ref-number-fig:before{content:"Figure "}.cross-ref-tab:before,.ref-number-tab:before{content:"Table "}.cross-ref-eqn:before,.MathJax_ref:has(mjx-mtext>mjx-c+mjx-c):before{content:"Equation "}.abstract,#refs{&:before{margin:1em auto;font-weight:700;display:block}}.abstract:before{content:"Abstract";text-align:center}#refs:before{content:"Bibliography";font-size:1.5em}.ref-paren-open:before{content:"("}.ref-paren-close:after{content:")"}.ref-semicolon:after{content:"; "}.ref-and:after{content:" and "}.ref-et-al:after{content:" et al.";font-style:italic}.footnote-ref a{&:before{content:"["}&:after{content:"]"}}section.footnotes{margin-top:2em;&:before{content:"";max-width:20em;display:block}}.fade{opacity:.6;background:repeating-linear-gradient(135deg,#fff,#fff 30px,#ddd 32px 32px)}@media print{body{max-width:100%}tr,img{break-inside:avoid}}@media only screen and (width>=992px){body:not(.pagesjs) pre:has(.line-numbers):not(:hover){white-space:pre}}
|
|
2
2
|
/*# sourceMappingURL=default.min.css.map */
|
package/css/default.min.css.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"mappings":"AAAA,oFAOA,oEACA,sBACA,iEACA,uCACA,gBACA,uBACA,+CACA,mDACA,2FACA,iEACA,oIACA,SACE,+BACA,kDACA,iDAEF,yCACA,oEAIE,yBAEF,oCACA,6BACA,QAAU,+CACV,qDACA,+DACA,6DAGE,yCAEF,kCACE,uDAEF,2EAMA,4CACA,+BACA,KACE,yBACA,eACA,
|
|
1
|
+
{"version":3,"mappings":"AAAA,oFAOA,oEACA,sBACA,iEACA,uCACA,gBACA,uBACA,+CACA,mDACA,2FACA,iEACA,oIACA,SACE,+BACA,kDACA,iDAEF,yCACA,oEAIE,yBAEF,oCACA,6BACA,QAAU,+CACV,qDACA,+DACA,6DAGE,yCAEF,kCACE,uDAEF,2EAMA,4CACA,+BACA,KACE,yBACA,sCACA,eACA,uCAEF,yDACA,wDACA,+BACA,yCACA,wDACA,yCACA,yCACA,+DACA,8DACA,yFACA,gBACE,wDAEF,sDACA,oDACA,mCACA,mCACA,kCACA,+BACA,qDACA,gBACE,qBACA,qBAEF,iCAEE,kDAEF,4FAKA,aACE,oBACA,2BAEF,sCACE","sources":["default.css"],"sourcesContent":["body {\n font-family: sans-serif;\n max-width: 800px;\n margin: auto;\n padding: 1em;\n line-height: 1.5;\n}\nbody, .abstract, code, .footnotes, footer, #refs, .caption { font-size: .9em; }\nli li { font-size: .95em; }\nul:has(li > input[type=\"checkbox\"]) { list-style: none; padding-left: 1em; }\n*, :before, :after { box-sizing: border-box; }\na { color: steelblue; }\npre, img { max-width: 100%; }\npre { white-space: pre-wrap; word-break: break-word; }\npre code { display: block; padding: 1em; overflow-x: auto; }\ncode { font-family: 'DejaVu Sans Mono', 'Droid Sans Mono', 'Lucida Console', Consolas, Monaco, monospace; }\n:not(pre) > code, code[class], div > .caption { background-color: #f8f8f8; }\npre > code:is(:not([class]), .language-plain, .language-none, .plain), .box, .figure, .table { background-color: inherit; border: 1px solid #eee; }\npre > code {\n &.message { border-color: #9eeaf9; }\n &.warning { background: #fff3cd; border-color: #fff3cd; }\n &.error { background: #f8d7da; border-color: #f8d7da; }\n}\n.fenced-chunk { border-left: 1px solid #666; }\n.code-fence {\n opacity: .4;\n border: 1px dashed #666;\n border-left: 2px solid;\n &:hover { opacity: inherit; }\n}\n.box, .figure, .table { margin: 1em auto; }\ndiv > .caption { padding: 1px 1em; }\n.figure { p:has(img), pre:has(svg) { text-align: center; } }\n.flex-col { display: flex; justify-content: space-between; }\ntable :is(th, td) { padding: 5px; font-variant-numeric: tabular-nums; }\ntable:not([class]) {\n margin: 1em auto;\n border-top: 1px solid #666;\n thead th { border-bottom: 1px solid #ddd; }\n}\ntable:not([class]), .table-striped {\n thead, tfoot, tr:nth-child(even) { background: whitesmoke; }\n}\nblockquote {\n color: #666;\n margin: 0;\n padding: 1px 1em;\n border-left: .5em solid #eee;\n}\nhr, .footnotes::before { border: 1px dashed #ddd; }\n.frontmatter { text-align: center; }\n#TOC {\n a { text-decoration: none; }\n ul { list-style: none; padding-left: 1em; }\n & > ul { padding: 0; }\n ul ul { border-left: 1px solid lightsteelblue; }\n}\ntable:not([class]), .body h2 { border-bottom: 1px solid #666; }\n.body .appendix, .appendix ~ h2 { border-bottom-style: dashed; }\n.main-number::after { content: \".\"; }\nspan[class^=\"ref-number-\"] { font-weight: bold; }\n.ref-number-fig::after, .ref-number-tab::after { content: \":\"; }\n.cross-ref-chp::before { content: \"Chapter \"; }\n.cross-ref-sec::before { content: \"Section \"; }\n.cross-ref-fig::before, .ref-number-fig::before { content: \"Figure \"; }\n.cross-ref-tab::before, .ref-number-tab::before { content: \"Table \"; }\n.cross-ref-eqn::before, .MathJax_ref:has(mjx-mtext > mjx-c + mjx-c)::before { content: \"Equation \"; }\n.abstract, #refs {\n &::before { display: block; margin: 1em auto; font-weight: bold; }\n}\n.abstract::before { content: \"Abstract\"; text-align: center; }\n#refs::before { content: \"Bibliography\"; font-size: 1.5em; }\n.ref-paren-open::before { content: \"(\"; }\n.ref-paren-close::after { content: \")\"; }\n.ref-semicolon::after { content: \"; \"; }\n.ref-and::after { content: \" and \"; }\n.ref-et-al::after { content: \" et al.\"; font-style: italic; }\n.footnote-ref a {\n &::before { content: \"[\"; }\n &::after { content: \"]\"; }\n}\nsection.footnotes {\n margin-top: 2em;\n &::before { content: \"\"; display: block; max-width: 20em; }\n}\n.fade {\n background: repeating-linear-gradient(135deg, white, white 30px, #ddd 32px, #ddd 32px);\n opacity: 0.6;\n}\n\n@media print {\n body { max-width: 100%; }\n tr, img { break-inside: avoid; }\n}\n@media only screen and (min-width: 992px) {\n body:not(.pagesjs) pre:has(.line-numbers):not(:hover) { white-space: pre; }\n}\n"],"names":[]}
|
package/css/heading-anchor.css
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
.anchor{display:none}:
|
|
1
|
+
.anchor{&:not(:hover>*){display:none}&>a:before{content:"#"}}
|
|
2
2
|
/*# sourceMappingURL=heading-anchor.min.css.map */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"mappings":"AAAA,
|
|
1
|
+
{"version":3,"mappings":"AAAA,QACE,6BACA","sources":["heading-anchor.css"],"sourcesContent":[".anchor {\n &:not(:hover > *) { display: none; }\n & > a::before { content: \"#\"; }\n}\n"],"names":[]}
|
package/js/heading-anchor.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
document.querySelectorAll('h1,h2,h3,h4,h5,h6').forEach(h => {
|
|
2
2
|
if (h.id && !h.querySelector('.anchor'))
|
|
3
|
-
h.insertAdjacentHTML('beforeend', ` <span class="anchor"><a href="#${h.id}"
|
|
3
|
+
h.insertAdjacentHTML('beforeend', ` <span class="anchor"><a href="#${h.id}"></a></span>`);
|
|
4
4
|
});
|
package/js/heading-anchor.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
document.querySelectorAll("h1,h2,h3,h4,h5,h6").forEach((e=>{e.id&&!e.querySelector(".anchor")&&e.insertAdjacentHTML("beforeend",` <span class="anchor"><a href="#${e.id}"
|
|
1
|
+
document.querySelectorAll("h1,h2,h3,h4,h5,h6").forEach((e=>{e.id&&!e.querySelector(".anchor")&&e.insertAdjacentHTML("beforeend",` <span class="anchor"><a href="#${e.id}"></a></span>`)}));
|
|
2
2
|
//# sourceMappingURL=heading-anchor.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["document","querySelectorAll","forEach","h","id","querySelector","insertAdjacentHTML"],"sources":["heading-anchor.js"],"mappings":"AAAAA,SAASC,iBAAiB,qBAAqBC,SAAQC,IACjDA,EAAEC,KAAOD,EAAEE,cAAc,YAC3BF,EAAEG,mBAAmB,YAAa,mCAAmCH,EAAEC,
|
|
1
|
+
{"version":3,"names":["document","querySelectorAll","forEach","h","id","querySelector","insertAdjacentHTML"],"sources":["heading-anchor.js"],"mappings":"AAAAA,SAASC,iBAAiB,qBAAqBC,SAAQC,IACjDA,EAAEC,KAAOD,EAAEE,cAAc,YAC3BF,EAAEG,mBAAmB,YAAa,mCAAmCH,EAAEC,kBAAkB","ignoreList":[]}
|
package/js/pages.js
CHANGED
|
@@ -5,7 +5,11 @@
|
|
|
5
5
|
function $$(s, el = d) { return el ? el.querySelectorAll(s) : []; }
|
|
6
6
|
function nChild(el) { return el.childElementCount; }
|
|
7
7
|
|
|
8
|
-
const tpl = d.createElement('div'), book = $$('h1').length > 1,
|
|
8
|
+
const tpl = d.createElement('div'), book = $$('h1').length > 1, boxes = [],
|
|
9
|
+
fr_cls = 'pagesjs-fragmented', tb = ['top', 'bottom'].map(i => {
|
|
10
|
+
const v = getComputedStyle(d.documentElement).getPropertyValue(`--paper-margin-${i}`);
|
|
11
|
+
return +v.replace('px', '') || 0;
|
|
12
|
+
}); // top/bottom page margin
|
|
9
13
|
tpl.className = 'pagesjs-page';
|
|
10
14
|
tpl.innerHTML = `<div class="pagesjs-header"></div>
|
|
11
15
|
<div class="pagesjs-body"></div>
|
|
@@ -15,12 +19,16 @@
|
|
|
15
19
|
el && !$('.pagesjs-body', el) && el.insertAdjacentHTML('afterbegin', tpl.innerHTML);
|
|
16
20
|
box = el || tpl.cloneNode(true); box_body = box.children[1];
|
|
17
21
|
box_cls.length && box.classList.add(...box_cls);
|
|
22
|
+
boxes.push(box); // store new pages in boxes
|
|
18
23
|
return box;
|
|
19
24
|
}
|
|
20
|
-
function
|
|
21
|
-
const
|
|
22
|
-
(
|
|
23
|
-
|
|
25
|
+
function addOffset(box) {
|
|
26
|
+
const h = box.scrollHeight;
|
|
27
|
+
if (h > H && !box.dataset.pagesOffset) {
|
|
28
|
+
const n = calcPages(box, h);
|
|
29
|
+
if (n > 1) box.dataset.pagesOffset = n;
|
|
30
|
+
}
|
|
31
|
+
box.classList.add('pagesjs-done');
|
|
24
32
|
}
|
|
25
33
|
function removeBlank(el) {
|
|
26
34
|
if (!el) return false;
|
|
@@ -29,6 +37,7 @@
|
|
|
29
37
|
return v;
|
|
30
38
|
}
|
|
31
39
|
function fill(el) {
|
|
40
|
+
const n1 = boxes.length;
|
|
32
41
|
// if the element is already a page, just use it as the box
|
|
33
42
|
if (el.classList.contains('pagesjs-page')) {
|
|
34
43
|
box.after(newPage(el));
|
|
@@ -36,20 +45,22 @@
|
|
|
36
45
|
if (nChild(el) > 3) {
|
|
37
46
|
box_body.append(...[...el.children].slice(3));
|
|
38
47
|
// TODO: should we fragment this page if it's too long?
|
|
39
|
-
testHeight(box, true);
|
|
40
48
|
box.after(newPage()); // create a new empty page
|
|
41
49
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
} else {
|
|
51
|
+
// create a new box when too much content (exceeding original height)
|
|
52
|
+
if (box.scrollHeight > H) {
|
|
53
|
+
const [box2, box_body2] = [box, box_body]; // store old box
|
|
54
|
+
box2.after(newPage());
|
|
55
|
+
// if there's more than one child in the box, move the last child to next box
|
|
56
|
+
nChild(box_body2) > 1 && box_body.append(box_body2.lastChild);
|
|
57
|
+
}
|
|
58
|
+
box_body.append(el);
|
|
59
|
+
fragment(el);
|
|
50
60
|
}
|
|
51
|
-
|
|
52
|
-
|
|
61
|
+
const n2 = boxes.length;
|
|
62
|
+
// mark all boxes (except the last one) with class 'pagesjs-done'
|
|
63
|
+
n2 > n1 && n2 > 1 && boxes.splice(0, n2 - 1).forEach(addOffset);
|
|
53
64
|
}
|
|
54
65
|
// break elements that are relatively easy to break (such as <ul>)
|
|
55
66
|
function fragment(el, container, parent, page) {
|
|
@@ -77,7 +88,7 @@
|
|
|
77
88
|
el2.append(item);
|
|
78
89
|
// usually there's no need to re-calculate size if item is not element (e.g., white space)
|
|
79
90
|
if (item.nodeName.startsWith('#')) continue;
|
|
80
|
-
if (
|
|
91
|
+
if (box_cur.scrollHeight > H) {
|
|
81
92
|
// move item back to el if the clone el2 is not the only element on page or has more than one child
|
|
82
93
|
(prev || nChild(el2) > 1) && el.insertBefore(item, el.firstChild);
|
|
83
94
|
// update the start number of <ol> on next page
|
|
@@ -90,7 +101,7 @@
|
|
|
90
101
|
const code = el.innerHTML.split('\n'), code2 = [];
|
|
91
102
|
for (let i of code) {
|
|
92
103
|
code2.push(i); el2.innerHTML = code2.join('\n');
|
|
93
|
-
if (
|
|
104
|
+
if (box_cur.scrollHeight > H) {
|
|
94
105
|
code2.pop(); el2.innerHTML = code2.join('\n');
|
|
95
106
|
break;
|
|
96
107
|
}
|
|
@@ -111,19 +122,14 @@
|
|
|
111
122
|
return h && (h.dataset.shortTitle || h.innerText);
|
|
112
123
|
}
|
|
113
124
|
const main = shortTitle($('h1.title, .frontmatter h1, .title, h1')), // main title
|
|
114
|
-
ps = (book ? 'h1' : 'h2') + ':not(.frontmatter *)'
|
|
115
|
-
tb = ['top', 'bottom'].map(i => {
|
|
116
|
-
const v = getComputedStyle(d.documentElement).getPropertyValue(`--paper-margin-${i}`);
|
|
117
|
-
return +v.replace('px', '') || 0;
|
|
118
|
-
}); // top/bottom page margin
|
|
125
|
+
ps = (book ? 'h1' : 'h2') + ':not(.frontmatter *)'; // page title selector
|
|
119
126
|
|
|
120
127
|
// calculate how many new pages we need for overflowed content (this is just
|
|
121
128
|
// an estimate; if not accurate, use <div class="pagesjs-page" data-pages-offset="N">
|
|
122
129
|
// to provide a number manually)
|
|
123
|
-
function calcPages(box) {
|
|
130
|
+
function calcPages(box, h) {
|
|
124
131
|
let n = +box.dataset.pagesOffset;
|
|
125
132
|
if (n) return n;
|
|
126
|
-
const h = box.scrollHeight;
|
|
127
133
|
n = Math.ceil(h/H);
|
|
128
134
|
if (n <= 1) return n;
|
|
129
135
|
// consider top/bottom page margin and table headers (which may be repeated on each page)
|
|
@@ -177,18 +183,18 @@
|
|
|
177
183
|
// clean up container and self if empty
|
|
178
184
|
removeBlank(el.parentNode); removeBlank(el);
|
|
179
185
|
});
|
|
186
|
+
boxes.forEach(addOffset); // mark the rest of pages as done
|
|
180
187
|
cls.remove('pagesjs-filling');
|
|
181
188
|
|
|
182
189
|
// add page number, title, etc. to data-* attributes of page elements
|
|
183
190
|
let page_title, i = 0;
|
|
184
191
|
$$('.pagesjs-page').forEach(box => {
|
|
185
192
|
if (removeBlank(box)) return; // remove empty pages
|
|
186
|
-
box.classList.remove('pagesjs-done');
|
|
187
193
|
if (book) {
|
|
188
194
|
if ($('.frontmatter', box)) return; // skip book frontmatter page
|
|
189
195
|
$(ps, box) && (page_title = ''); // empty title for first page of chapter
|
|
190
196
|
}
|
|
191
|
-
const N =
|
|
197
|
+
const N = +box.dataset.pagesOffset || 1;
|
|
192
198
|
if (N > 1) box.classList.add('page-multiple');
|
|
193
199
|
i += N;
|
|
194
200
|
box.classList.add(`page-${i % 2 === 0 ? 'even' : 'odd'}`);
|
|
@@ -213,6 +219,9 @@
|
|
|
213
219
|
p = $(`.pagesjs-page:has(#${id}) .pagesjs-header`);
|
|
214
220
|
a.dataset.pageNumber = p ? p.dataset.pageNumber : '';
|
|
215
221
|
});
|
|
222
|
+
|
|
223
|
+
// unhide all pages
|
|
224
|
+
$$('.pagesjs-done').forEach(box => box.classList.remove('pagesjs-done'));
|
|
216
225
|
}
|
|
217
226
|
addEventListener('beforeprint', paginate);
|
|
218
227
|
// persistent pagination upon page reload (press p again to cancel it)
|
package/js/pages.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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
|
|
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 a=e.createElement("div"),r=n("h1").length>1,i=[],o="pagesjs-fragmented",c=["top","bottom"].map((t=>+getComputedStyle(e.documentElement).getPropertyValue(`--paper-margin-${t}`).replace("px","")||0));a.className="pagesjs-page",a.innerHTML='<div class="pagesjs-header"></div>\n<div class="pagesjs-body"></div>\n<div class="pagesjs-footer"></div>';let l,d,f,p=[];function g(e){return e&&!t(".pagesjs-body",e)&&e.insertAdjacentHTML("afterbegin",a.innerHTML),l=e||a.cloneNode(!0),d=l.children[1],p.length&&l.classList.add(...p),i.push(l),l}function h(e){const t=e.scrollHeight;if(t>f&&!e.dataset.pagesOffset){const s=function(e,t){let s=+e.dataset.pagesOffset;if(s)return s;if(s=Math.ceil(t/f),s<=1)return s;const a=c.concat([...n("thead",e)].map((e=>+e.offsetHeight))).reduce(((e,t)=>e+t));if(!a)return s;function r(){return Math.ceil((t+(s-1)*a)/f)}let i=r();for(;i>s;)s=i,i=r();return s}(e,t);s>1&&(e.dataset.pagesOffset=s)}e.classList.add("pagesjs-done")}function u(e){if(!e)return!1;const t=""===e.innerText.trim();return t&&e.remove(),t}function m(e){const t=i.length;if(e.classList.contains("pagesjs-page"))l.after(g(e)),s(e)>3&&(d.append(...[...e.children].slice(3)),l.after(g()));else{if(l.scrollHeight>f){const[e,t]=[l,d];e.after(g()),s(t)>1&&d.append(t.lastChild)}d.append(e),E(e)}const n=i.length;n>t&&n>1&&i.splice(0,n-1).forEach(h)}function E(e,t,n,a){const r=e.tagName,i="CODE"===r;if((!i||!t)&&l.scrollHeight<=f)return;e.classList.add(o);const c=a||l,p=e.cloneNode();if(t?t.append(p):(d.append(p),c.after(g()),d.append(e)),"PRE"===r){const t=e.firstElementChild;"CODE"==t?.tagName&&/\n/.test(t.innerHTML)&&E(t,p,e,c)}else"DIV"===r&&1===s(e)&&E(e.firstElementChild,p,e,c);const h=p.previousElementSibling;if(["UL","OL","BLOCKQUOTE"].includes(r)&&s(e)>1)for(;;){const t=e.firstChild;if(!t)break;if(p.append(t),!t.nodeName.startsWith("#")&&c.scrollHeight>f){(h||s(p)>1)&&e.insertBefore(t,e.firstChild),"OL"===r&&(e.start+=s(p));break}}if(i){const t=e.innerHTML.split("\n"),s=[];for(let e of t)if(s.push(e),p.innerHTML=s.join("\n"),c.scrollHeight>f){s.pop(),p.innerHTML=s.join("\n");break}if(s.length>0&&(e.innerHTML=t.slice(s.length).join("\n"),u(n)))return}const m=u(p);m&&e.classList.remove(o),(!m||i||h)&&E(t?n:e)}function L(e){return e&&(e.dataset.shortTitle||e.innerText)}const j=L(t("h1.title, .frontmatter h1, .title, h1")),b=(r?"h1":"h2")+":not(.frontmatter *)";function T(){if("complete"!==e.readyState)return setTimeout(T,10);const s=e.body.classList;if(s.contains("pagesjs"))return;s.add("pagesjs"),e.body.insertAdjacentElement("afterbegin",g()),f=l.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"})),[t(".frontmatter"),t("#TOC"),t(".abstract")].forEach((e=>{e&&(m(e),r&&l.after(g()))})),n(".body").forEach((e=>{p=["chapter","appendix"].filter((t=>e.classList.contains(t))),r&&(""===l.innerText?g(l):l.after(g())),[...e.children].map(m),u(e.parentNode),u(e)})),i.forEach(h),s.remove("pagesjs-filling");let a,o=0;n(".pagesjs-page").forEach((e=>{if(u(e))return;if(r){if(t(".frontmatter",e))return;t(b,e)&&(a="")}const s=+e.dataset.pagesOffset||1;s>1&&e.classList.add("page-multiple"),o+=s,e.classList.add("page-"+(o%2==0?"even":"odd"));const i={pageNumber:o,mainTitle:j,pageTitle:a};let c;[e.children[0],e.children[2]].forEach((e=>{for(const t in i)i[t]&&(e.dataset[t]=i[t])})),a=L([...n(b,e)].pop())||a,n(".footnotes",e).forEach(((t,n)=>{0===n?(c=t,e.children[1].after(t)):(c.append(...t.children),t.remove())}))})),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:""})),n(".pagesjs-done").forEach((e=>e.classList.remove("pagesjs-done")))}addEventListener("beforeprint",T);let v=sessionStorage.getItem("pagesjs");v&&T(),addEventListener("keypress",(e=>"p"===e.key&&(T(),v=v?"":"1",sessionStorage.setItem("pagesjs",v),v||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","fr_cls","
|
|
1
|
+
{"version":3,"names":["d","$","s","el","querySelector","$$","querySelectorAll","nChild","childElementCount","tpl","createElement","book","length","boxes","fr_cls","tb","map","i","getComputedStyle","documentElement","getPropertyValue","replace","className","innerHTML","box","box_body","H","box_cls","newPage","insertAdjacentHTML","cloneNode","children","classList","add","push","addOffset","h","scrollHeight","dataset","pagesOffset","n","Math","ceil","m","concat","offsetHeight","reduce","m1","m2","newPages","n2","calcPages","removeBlank","v","innerText","trim","remove","fill","n1","contains","after","append","slice","box2","box_body2","lastChild","fragment","splice","forEach","container","parent","page","tag","tagName","is_code","box_cur","el2","code","firstElementChild","test","prev","previousElementSibling","includes","item","firstChild","nodeName","startsWith","insertBefore","start","split","code2","join","pop","el2_empty","shortTitle","main","ps","paginate","readyState","setTimeout","cls","body","insertAdjacentElement","clientHeight","window","innerHeight","a","nextSibling","pageNumber","filter","parentNode","page_title","N","info","mainTitle","pageTitle","ft","key","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,EAAEU,cAAc,OAAQC,EAAON,EAAG,MAAMO,OAAS,EAAGC,EAAQ,GACxEC,EAAS,qBAAsBC,EAAK,CAAC,MAAO,UAAUC,KAAIC,IAC5CC,iBAAiBlB,EAAEmB,iBAAiBC,iBAAiB,kBAAkBH,KACvEI,QAAQ,KAAM,KAAO,IAEnCZ,EAAIa,UAAY,eAChBb,EAAIc,UAAY,2GAGhB,IAAIC,EAAKC,EAAUC,EAAGC,EAAU,GAChC,SAASC,EAAQzB,GAKf,OAJAA,IAAOF,EAAE,gBAAiBE,IAAOA,EAAG0B,mBAAmB,aAAcpB,EAAIc,WACzEC,EAAMrB,GAAMM,EAAIqB,WAAU,GAAOL,EAAWD,EAAIO,SAAS,GACzDJ,EAAQf,QAAUY,EAAIQ,UAAUC,OAAON,GACvCd,EAAMqB,KAAKV,GACJA,CACT,CACA,SAASW,EAAUX,GACjB,MAAMY,EAAIZ,EAAIa,aACd,GAAID,EAAIV,IAAMF,EAAIc,QAAQC,YAAa,CACrC,MAAMC,EAsGV,SAAmBhB,EAAKY,GACtB,IAAII,GAAKhB,EAAIc,QAAQC,YACrB,GAAIC,EAAG,OAAOA,EAEd,GADAA,EAAIC,KAAKC,KAAKN,EAAEV,GACZ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