@xiee/utils 1.13.35 → 1.13.37

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 CHANGED
@@ -62,6 +62,7 @@ table, .body h2 { border-bottom: 1px solid #666; }
62
62
  .cross-ref-sec::before { content: "Section "; }
63
63
  .cross-ref-fig::before, .ref-number-fig::before { content: "Figure "; }
64
64
  .cross-ref-tab::before, .ref-number-tab::before { content: "Table "; }
65
+ .cross-ref-eqn::before { content: "Equation "; }
65
66
  .abstract, #refs {
66
67
  &::before { display: block; margin: 1em auto; font-weight: bold; }
67
68
  }
@@ -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,#refs{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,pre:hover{white-space:pre-wrap;word-break:break-all}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],.box>div{background-color:#f8f8f8}pre>code:not([class]),pre>.language-plain,.box{background-color:inherit;border:1px solid #eee}pre>.message{border-color:#9eeaf9}pre>.warning{background:#fff3cd;border-color:#fff3cd}pre>.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{margin:1em 0}.box>:first-child>p:first-child,.box>:last-child>p:last-child{padding:1em}.box>:first-child,.box>:first-child>p:first-child{margin-top:0}.box>:last-child,.box>:last-child>p:last-child{margin-bottom:0}.figure>p:has(img){text-align:center}table{border-top:1px solid #666;margin:auto;& thead th{border-bottom:1px solid #ddd}& th,& td{padding:5px}& thead,& tfoot,& tr:nth-child(2n){background:#eee}}.table-full{width:100%;& td{vertical-align:baseline}}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 .numbered{padding-left:0;& li{list-style:none}& ul{padding-left:1em}}table,.body h2{border-bottom:1px solid #666}.body .appendix,.appendix~h2{border-bottom-style:dashed}.main-number:after{content:"."}.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 "}.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}}@media print{body{max-width:100%}tr,img{page-break-inside:avoid}}@media only screen and (width>=992px){pre{white-space:pre}}
1
+ body{max-width:800px;margin:auto;padding:1em;font-family:sans-serif;line-height:1.5}body,.abstract,code,.footnotes,#refs{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,pre:hover{white-space:pre-wrap;word-break:break-all}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],.box>div{background-color:#f8f8f8}pre>code:not([class]),pre>.language-plain,.box{background-color:inherit;border:1px solid #eee}pre>.message{border-color:#9eeaf9}pre>.warning{background:#fff3cd;border-color:#fff3cd}pre>.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{margin:1em 0}.box>:first-child>p:first-child,.box>:last-child>p:last-child{padding:1em}.box>:first-child,.box>:first-child>p:first-child{margin-top:0}.box>:last-child,.box>:last-child>p:last-child{margin-bottom:0}.figure>p:has(img){text-align:center}table{border-top:1px solid #666;margin:auto;& thead th{border-bottom:1px solid #ddd}& th,& td{padding:5px}& thead,& tfoot,& tr:nth-child(2n){background:#eee}}.table-full{width:100%;& td{vertical-align:baseline}}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 .numbered{padding-left:0;& li{list-style:none}& ul{padding-left:1em}}table,.body h2{border-bottom:1px solid #666}.body .appendix,.appendix~h2{border-bottom-style:dashed}.main-number:after{content:"."}.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{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}}@media print{body{max-width:100%}tr,img{page-break-inside:avoid}}@media only screen and (width>=992px){pre{white-space:pre}}
2
2
  /*# sourceMappingURL=default.min.css.map */
@@ -1 +1 @@
1
- {"version":3,"mappings":"AAAA,oFAOA,oDACA,sBACA,iEACA,uCACA,gBACA,uBACA,wDACA,mDACA,2FACA,6DACA,8FACA,kCACA,qDACA,mDACA,yCACA,oEAIE,yBAEF,kBACA,0EACA,+DACA,+DACA,qCACA,4CAEE,wCACA,sBACA,oDAEF,uBAEE,8BAEF,2EAMA,4CACA,+BACA,8BAEE,qBACA,uBAEF,4CACA,wDACA,+BACA,wDACA,yCACA,yCACA,+DACA,8DACA,gBACE,wDAEF,sDACA,oDACA,mCACA,mCACA,kCACA,+BACA,qDACA,gBACE,qBACA,qBAEF,iCAEE,kDAGF,aACE,oBACA,gCAEF,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, #refs { 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, pre:hover { white-space: pre-wrap; word-break: break-all; }\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], .box > div { background-color: #f8f8f8; }\npre > code:not([class]), pre > .language-plain, .box { background-color: inherit; border: 1px solid #eee; }\npre > .message { border-color: #9eeaf9; }\npre > .warning { background: #fff3cd; border-color: #fff3cd; }\npre > .error { background: #f8d7da; border-color: #f8d7da; }\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 { margin: 1em 0; }\n.box > :first-child > p:first-child, .box > :last-child > p:last-child { padding: 1em; }\n.box > :first-child, .box > :first-child > p:first-child { margin-top: 0; }\n.box > :last-child, .box > :last-child > p:last-child { margin-bottom: 0; }\n.figure > p:has(img) { text-align: center; }\ntable {\n margin: auto; border-top: 1px solid #666;\n thead th { border-bottom: 1px solid #ddd; }\n th, td { padding: 5px; }\n thead, tfoot, tr:nth-child(even) { background: #eee; }\n}\n.table-full {\n width: 100%;\n td { vertical-align: baseline; }\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 .numbered {\n padding-left: 0;\n li { list-style: none; }\n ul { padding-left: 1em; }\n}\ntable, .body h2 { border-bottom: 1px solid #666; }\n.body .appendix, .appendix ~ h2 { border-bottom-style: dashed; }\n.main-number::after { content: \".\"; }\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.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\n@media print {\n body { max-width: 100%; }\n tr, img { page-break-inside: avoid; }\n}\n@media only screen and (min-width: 992px) {\n pre { white-space: pre; }\n}\n"],"names":[]}
1
+ {"version":3,"mappings":"AAAA,oFAOA,oDACA,sBACA,iEACA,uCACA,gBACA,uBACA,wDACA,mDACA,2FACA,6DACA,8FACA,kCACA,qDACA,mDACA,yCACA,oEAIE,yBAEF,kBACA,0EACA,+DACA,+DACA,qCACA,4CAEE,wCACA,sBACA,oDAEF,uBAEE,8BAEF,2EAMA,4CACA,+BACA,8BAEE,qBACA,uBAEF,4CACA,wDACA,+BACA,wDACA,yCACA,yCACA,+DACA,8DACA,0CACA,gBACE,wDAEF,sDACA,oDACA,mCACA,mCACA,kCACA,+BACA,qDACA,gBACE,qBACA,qBAEF,iCAEE,kDAGF,aACE,oBACA,gCAEF,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, #refs { 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, pre:hover { white-space: pre-wrap; word-break: break-all; }\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], .box > div { background-color: #f8f8f8; }\npre > code:not([class]), pre > .language-plain, .box { background-color: inherit; border: 1px solid #eee; }\npre > .message { border-color: #9eeaf9; }\npre > .warning { background: #fff3cd; border-color: #fff3cd; }\npre > .error { background: #f8d7da; border-color: #f8d7da; }\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 { margin: 1em 0; }\n.box > :first-child > p:first-child, .box > :last-child > p:last-child { padding: 1em; }\n.box > :first-child, .box > :first-child > p:first-child { margin-top: 0; }\n.box > :last-child, .box > :last-child > p:last-child { margin-bottom: 0; }\n.figure > p:has(img) { text-align: center; }\ntable {\n margin: auto; border-top: 1px solid #666;\n thead th { border-bottom: 1px solid #ddd; }\n th, td { padding: 5px; }\n thead, tfoot, tr:nth-child(even) { background: #eee; }\n}\n.table-full {\n width: 100%;\n td { vertical-align: baseline; }\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 .numbered {\n padding-left: 0;\n li { list-style: none; }\n ul { padding-left: 1em; }\n}\ntable, .body h2 { border-bottom: 1px solid #666; }\n.body .appendix, .appendix ~ h2 { border-bottom-style: dashed; }\n.main-number::after { content: \".\"; }\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 { 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\n@media print {\n body { max-width: 100%; }\n tr, img { page-break-inside: avoid; }\n}\n@media only screen and (min-width: 992px) {\n pre { white-space: pre; }\n}\n"],"names":[]}
@@ -0,0 +1,7 @@
1
+ // enable MathJax equation numbering: https://docs.mathjax.org/en/latest/input/tex/eqnumbers.html
2
+ (() => {
3
+ m = window.MathJax || {}; // make sure not to override existing config
4
+ m.tex = m.tex || {};
5
+ m.tex.tags = m.tex.tags || 'ams';
6
+ window.MathJax = m;
7
+ })();
@@ -0,0 +1 @@
1
+ m=window.MathJax||{},m.tex=m.tex||{},m.tex.tags=m.tex.tags||"ams",window.MathJax=m;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["m","window","MathJax","tex","tags"],"sources":["mathjax-config.js"],"mappings":"AAEEA,EAAIC,OAAOC,SAAW,CAAC,EACvBF,EAAEG,IAAMH,EAAEG,KAAO,CAAC,EAClBH,EAAEG,IAAIC,KAAOJ,EAAEG,IAAIC,MAAQ,MAC3BH,OAAOC,QAAUF","ignoreList":[]}
package/js/pages.js CHANGED
@@ -64,7 +64,7 @@
64
64
  }
65
65
  const prev = el2.previousElementSibling;
66
66
  // keep moving el's first item to el2 until page height > H
67
- if (['UL', 'BLOCKQUOTE'].indexOf(tag) > -1 && nChild(el) > 1) while (true) {
67
+ if (['UL', 'BLOCKQUOTE'].includes(tag) && nChild(el) > 1) while (true) {
68
68
  const item = el.firstChild;
69
69
  if (!item) break;
70
70
  el2.append(item);
@@ -194,7 +194,8 @@
194
194
 
195
195
  // add page numbers to TOC with data-* attributes
196
196
  $$('#TOC a[href^="#"]').forEach(a => {
197
- const p = $(`.pagesjs-page:has(${a.getAttribute('href')}) .pagesjs-header`);
197
+ const id = CSS.escape(a.getAttribute('href').replace(/^#/, '')),
198
+ p = $(`.pagesjs-page:has(#${id}) .pagesjs-header`);
198
199
  a.dataset.pageNumber = p ? p.dataset.pageNumber : '';
199
200
  });
200
201
  }
package/js/pages.min.js CHANGED
@@ -1 +1 @@
1
- (e=>{function t(t,n=e){return n?.querySelector(t)}function n(t,n=e){return n?n.querySelectorAll(t):[]}function r(e){return e.childElementCount}const i=e.createElement("div"),a=n("h1").length>1;i.className="pagesjs-page",i.innerHTML='<div class="pagesjs-header"></div>\n<div class="pagesjs-body"></div>\n<div class="pagesjs-footer"></div>';let s,o,l,c=[];function d(e){return e&&!t(".pagesjs-body",e)&&e.insertAdjacentHTML("afterbegin",i.innerHTML),s=e||i.cloneNode(!0),o=s.children[1],c.length&&s.classList.add(...c),s}function f(e){if(!e)return!1;const t=""===e.innerText.trim();return t&&e.remove(),t}function p(e){if(e.classList.contains("pagesjs-page"))return s.after(d(e)),void(r(e)>3&&(o.append(...[...e.children].slice(3)),s.after(d())));if(s.scrollHeight>l){const[e,t]=[s,o];e.after(d()),r(t)>1&&o.append(t.lastChild)}o.append(e),g(e)}function g(e,t,n,i){const a=e.tagName,c="CODE"===a;if((!c||!t)&&s.scrollHeight<=l)return;const p=i||s,h=e.cloneNode();if(t?t.append(h):(o.append(h),p.after(d()),o.append(e)),"PRE"===a){const t=e.firstElementChild;"CODE"==t?.tagName&&/\n/.test(t.innerHTML)&&g(t,h,e,p)}else"DIV"===a&&1===r(e)&&g(e.firstElementChild,h,e,p);const u=h.previousElementSibling;if(["UL","BLOCKQUOTE"].indexOf(a)>-1&&r(e)>1)for(;;){const t=e.firstChild;if(!t)break;if(h.append(t),p.scrollHeight>l){(u||r(h)>1)&&e.insertBefore(t,e.firstChild);break}}if(c){const t=e.innerHTML.split("\n"),r=[];for(let e of t)if(r.push(e),h.innerHTML=r.join("\n"),p.scrollHeight>l){r.pop(),h.innerHTML=r.join("\n");break}if(r.length>0&&(e.innerHTML=t.slice(r.length).join("\n"),f(n)))return}(!f(h)||c||u)&&g(t?n:e)}function h(e){return e&&(e.dataset.shortTitle||e.innerText)}const u=h(t("h1.title, .frontmatter h1, .title, h1")),m=(a?"h1":"h2")+":not(.frontmatter *)",b=["top","bottom"].map((t=>+getComputedStyle(e.documentElement).getPropertyValue(`--paper-margin-${t}`).replace("px","")||0));function E(){if("complete"!==e.readyState)return setTimeout(E,10);const r=e.body.classList;if(r.contains("pagesjs"))return;r.add("pagesjs"),a&&r.add("page-book"),e.body.insertAdjacentElement("afterbegin",d()),l=s.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")})),r.add("pagesjs-filling"),[t(".frontmatter"),t("#TOC"),t(".abstract")].forEach((e=>{e&&(p(e),a&&s.after(d()))})),n(".body").forEach((e=>{c=["chapter","appendix"].filter((t=>e.classList.contains(t))),a&&(""===s.innerText?d(s):s.after(d())),[...e.children].map(p),f(e.parentNode),f(e)})),r.remove("pagesjs-filling"),n('#TOC a[href^="#"]').forEach((t=>{const n=e.createElement("span"),r=t.firstElementChild;for(r?.classList.contains("section-number")?r.after(n):t.insertAdjacentElement("afterbegin",n);n.nextSibling;)n.append(n.nextSibling);t.insertAdjacentHTML("beforeend",'<span class="dot-leader"></span>'),t.dataset.pageNumber="000"}));let i,o=0;n(".pagesjs-page").forEach((e=>{if(f(e))return;if(a){if(t(".frontmatter",e))return;t(m,e)&&(i="")}const r=function(e){let t=+e.dataset.pagesOffset;if(t)return t;const r=e.scrollHeight;if(t=Math.ceil(r/l),t<=1)return t;const i=b.concat([...n("thead",e)].map((e=>+e.offsetHeight))).reduce(((e,t)=>e+t));if(!i)return t;function a(){return Math.ceil((r+(t-1)*i)/l)}let s=a();for(;s>t;)t=s,s=a();return t}(e);r>1&&e.classList.add("page-multiple"),o+=r,e.classList.add("page-"+(o%2==0?"even":"odd"));const s={pageNumber:o,mainTitle:u,pageTitle:i};let c;[e.children[0],e.children[2]].forEach((e=>{for(const t in s)s[t]&&(e.dataset[t]=s[t])})),i=h([...n(m,e)].pop())||i,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(${e.getAttribute("href")}) .pagesjs-header`);e.dataset.pageNumber=n?n.dataset.pageNumber:""}))}addEventListener("beforeprint",E);let j=sessionStorage.getItem("pagesjs");j&&E(),addEventListener("keypress",(e=>"p"===e.key&&(E(),j=j?"":"1",sessionStorage.setItem("pagesjs",j),j||location.reload())))})(document);
1
+ (e=>{function t(t,n=e){return n?.querySelector(t)}function n(t,n=e){return n?n.querySelectorAll(t):[]}function r(e){return e.childElementCount}const a=e.createElement("div"),i=n("h1").length>1;a.className="pagesjs-page",a.innerHTML='<div class="pagesjs-header"></div>\n<div class="pagesjs-body"></div>\n<div class="pagesjs-footer"></div>';let s,o,c,l=[];function d(e){return e&&!t(".pagesjs-body",e)&&e.insertAdjacentHTML("afterbegin",a.innerHTML),s=e||a.cloneNode(!0),o=s.children[1],l.length&&s.classList.add(...l),s}function f(e){if(!e)return!1;const t=""===e.innerText.trim();return t&&e.remove(),t}function p(e){if(e.classList.contains("pagesjs-page"))return s.after(d(e)),void(r(e)>3&&(o.append(...[...e.children].slice(3)),s.after(d())));if(s.scrollHeight>c){const[e,t]=[s,o];e.after(d()),r(t)>1&&o.append(t.lastChild)}o.append(e),g(e)}function g(e,t,n,a){const i=e.tagName,l="CODE"===i;if((!l||!t)&&s.scrollHeight<=c)return;const p=a||s,h=e.cloneNode();if(t?t.append(h):(o.append(h),p.after(d()),o.append(e)),"PRE"===i){const t=e.firstElementChild;"CODE"==t?.tagName&&/\n/.test(t.innerHTML)&&g(t,h,e,p)}else"DIV"===i&&1===r(e)&&g(e.firstElementChild,h,e,p);const u=h.previousElementSibling;if(["UL","BLOCKQUOTE"].includes(i)&&r(e)>1)for(;;){const t=e.firstChild;if(!t)break;if(h.append(t),p.scrollHeight>c){(u||r(h)>1)&&e.insertBefore(t,e.firstChild);break}}if(l){const t=e.innerHTML.split("\n"),r=[];for(let e of t)if(r.push(e),h.innerHTML=r.join("\n"),p.scrollHeight>c){r.pop(),h.innerHTML=r.join("\n");break}if(r.length>0&&(e.innerHTML=t.slice(r.length).join("\n"),f(n)))return}(!f(h)||l||u)&&g(t?n:e)}function h(e){return e&&(e.dataset.shortTitle||e.innerText)}const u=h(t("h1.title, .frontmatter h1, .title, h1")),m=(i?"h1":"h2")+":not(.frontmatter *)",b=["top","bottom"].map((t=>+getComputedStyle(e.documentElement).getPropertyValue(`--paper-margin-${t}`).replace("px","")||0));function E(){if("complete"!==e.readyState)return setTimeout(E,10);const r=e.body.classList;if(r.contains("pagesjs"))return;r.add("pagesjs"),i&&r.add("page-book"),e.body.insertAdjacentElement("afterbegin",d()),c=s.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")})),r.add("pagesjs-filling"),[t(".frontmatter"),t("#TOC"),t(".abstract")].forEach((e=>{e&&(p(e),i&&s.after(d()))})),n(".body").forEach((e=>{l=["chapter","appendix"].filter((t=>e.classList.contains(t))),i&&(""===s.innerText?d(s):s.after(d())),[...e.children].map(p),f(e.parentNode),f(e)})),r.remove("pagesjs-filling"),n('#TOC a[href^="#"]').forEach((t=>{const n=e.createElement("span"),r=t.firstElementChild;for(r?.classList.contains("section-number")?r.after(n):t.insertAdjacentElement("afterbegin",n);n.nextSibling;)n.append(n.nextSibling);t.insertAdjacentHTML("beforeend",'<span class="dot-leader"></span>'),t.dataset.pageNumber="000"}));let a,o=0;n(".pagesjs-page").forEach((e=>{if(f(e))return;if(i){if(t(".frontmatter",e))return;t(m,e)&&(a="")}const r=function(e){let t=+e.dataset.pagesOffset;if(t)return t;const r=e.scrollHeight;if(t=Math.ceil(r/c),t<=1)return t;const a=b.concat([...n("thead",e)].map((e=>+e.offsetHeight))).reduce(((e,t)=>e+t));if(!a)return t;function i(){return Math.ceil((r+(t-1)*a)/c)}let s=i();for(;s>t;)t=s,s=i();return t}(e);r>1&&e.classList.add("page-multiple"),o+=r,e.classList.add("page-"+(o%2==0?"even":"odd"));const s={pageNumber:o,mainTitle:u,pageTitle:a};let l;[e.children[0],e.children[2]].forEach((e=>{for(const t in s)s[t]&&(e.dataset[t]=s[t])})),a=h([...n(m,e)].pop())||a,n(".footnotes",e).forEach(((t,n)=>{0===n?(l=t,e.children[1].after(t)):(l.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:""}))}addEventListener("beforeprint",E);let j=sessionStorage.getItem("pagesjs");j&&E(),addEventListener("keypress",(e=>"p"===e.key&&(E(),j=j?"":"1",sessionStorage.setItem("pagesjs",j),j||location.reload())))})(document);
@@ -1 +1 @@
1
- {"version":3,"names":["d","$","s","el","querySelector","$$","querySelectorAll","nChild","childElementCount","tpl","createElement","book","length","className","innerHTML","box","box_body","H","box_cls","newPage","insertAdjacentHTML","cloneNode","children","classList","add","removeBlank","v","innerText","trim","remove","fill","contains","after","append","slice","scrollHeight","box2","box_body2","lastChild","fragment","container","parent","page","tag","tagName","is_code","box_cur","el2","code","firstElementChild","test","prev","previousElementSibling","indexOf","item","firstChild","insertBefore","split","code2","i","push","join","pop","shortTitle","h","dataset","main","ps","tb","map","getComputedStyle","documentElement","getPropertyValue","replace","paginate","readyState","setTimeout","cls","body","insertAdjacentElement","clientHeight","window","innerHeight","forEach","filter","parentNode","a","n","nextSibling","pageNumber","page_title","N","pagesOffset","Math","ceil","m","concat","offsetHeight","reduce","m1","m2","newPages","n2","calcPages","info","mainTitle","pageTitle","ft","key","p","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,EAC7DH,EAAII,UAAY,eAChBJ,EAAIK,UAAY,2GAGhB,IAAIC,EAAKC,EAAUC,EAAGC,EAAU,GAChC,SAASC,EAAQhB,GAIf,OAHAA,IAAOF,EAAE,gBAAiBE,IAAOA,EAAGiB,mBAAmB,aAAcX,EAAIK,WACzEC,EAAMZ,GAAMM,EAAIY,WAAU,GAAOL,EAAWD,EAAIO,SAAS,GACzDJ,EAAQN,QAAUG,EAAIQ,UAAUC,OAAON,GAChCH,CACT,CACA,SAASU,EAAYtB,GACnB,IAAKA,EAAI,OAAO,EAChB,MAAMuB,EAA4B,KAAxBvB,EAAGwB,UAAUC,OAEvB,OADAF,GAAKvB,E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AKQ,GAAG9E,EAAI,CAC7D,IAAIqF,EAAKD,IACT,KAAOC,EAAKf,GACVA,EAAIe,EAAIA,EAAKD,IAEf,OAAOd,CACT,CAmDcgB,CAAUxF,GAChB4E,EAAI,GAAG5E,EAAIQ,UAAUC,IAAI,iBAC7BmC,GAAKgC,EACL5E,EAAIQ,UAAUC,IAAI,SAAQmC,EAAI,GAAM,EAAI,OAAS,QACjD,MAAM6C,EAAO,CACXf,WAAc9B,EAAG8C,UAAavC,EAAMwC,UAAahB,GAOnD,IAAIiB,EALJ,CAAC5F,EAAIO,SAAS,GAAIP,EAAIO,SAAS,IAAI6D,SAAQhF,IACzC,IAAK,MAAMyG,KAAOJ,EAAMA,EAAKI,KAASzG,EAAG8D,QAAQ2C,GAAOJ,EAAKI,GAAK,IAGpElB,EAAa3B,EAAW,IAAI1D,EAAG8D,EAAIpD,IAAM+C,QAAU4B,EAGnDrF,EAAG,aAAcU,GAAKoE,SAAQ,CAAChF,EAAIwD,KAC3B,IAANA,GAAWgD,EAAKxG,EAAIY,EAAIO,SAAS,GAAGU,MAAM7B,KAAQwG,EAAG1E,UAAU9B,EAAGmB,UAAWnB,EAAG0B,SAAS,GACzF,IAIJxB,EAAG,qBAAqB8E,SAAQG,IAC9B,MAAMuB,EAAI5G,EAAE,qBAAqBqF,EAAEwB,aAAa,4BAChDxB,EAAErB,QAAQwB,WAAaoB,EAAIA,EAAE5C,QAAQwB,WAAa,EAAE,GAExD,CACAsB,iBAAiB,cAAerC,GAEhC,IAAIsC,EAAKC,eAAeC,QAAQ,WAChCF,GAAMtC,IACNqC,iBAAiB,YAAYI,GAAe,MAAVA,EAAEP,MAClClC,IAAYsC,EAAKA,EAAK,GAAK,IAAKC,eAAeG,QAAQ,UAAWJ,GAAKA,GAAMK,SAASC,WAEzF,EA7MD,CA6MGC","ignoreList":[]}
1
+ {"version":3,"names":["d","$","s","el","querySelector","$$","querySelectorAll","nChild","childElementCount","tpl","createElement","book","length","className","innerHTML","box","box_body","H","box_cls","newPage","insertAdjacentHTML","cloneNode","children","classList","add","removeBlank","v","innerText","trim","remove","fill","contains","after","append","slice","scrollHeight","box2","box_body2","lastChild","fragment","container","parent","page","tag","tagName","is_code","box_cur","el2","code","firstElementChild","test","prev","previousElementSibling","includes","item","firstChild","insertBefore","split","code2","i","push","join","pop","shortTitle","h","dataset","main","ps","tb","map","getComputedStyle","documentElement","getPropertyValue","replace","paginate","readyState","setTimeout","cls","body","insertAdjacentElement","clientHeight","window","innerHeight","forEach","filter","parentNode","a","n","nextSibling","pageNumber","page_title","N","pagesOffset","Math","ceil","m","concat","offsetHeight","reduce","m1","m2","newPages","n2","calcPages","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,EAC7DH,EAAII,UAAY,eAChBJ,EAAIK,UAAY,2GAGhB,IAAIC,EAAKC,EAAUC,EAAGC,EAAU,GAChC,SAASC,EAAQhB,GAIf,OAHAA,IAAOF,EAAE,gBAAiBE,IAAOA,EAAGiB,mBAAmB,aAAcX,EAAIK,WACzEC,EAAMZ,GAAMM,EAAIY,WAAU,GAAOL,EAAWD,EAAIO,SAAS,GACzDJ,EAAQN,QAAUG,EAAIQ,UAAUC,OAAON,GAChCH,CACT,CACA,SAASU,EAAYtB,GACnB,IAAKA,EAAI,OAAO,EAChB,MAAMuB,EAA4B,KAAxBvB,EAAGwB,UAAUC,OAEvB,OADAF,GAAKvB,EAAG0B,SACDH,CACT,CACA,SAASI,E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(d => {
3
+ renderMathInElement(d.body, {
4
+ strict: false, throwOnError: false,
5
+ trust: context => ['\\href', '\\htmlId', '\\htmlClass'].includes(context.command),
6
+ macros: {
7
+ '\\eqref': '\\htmlClass{ktx-eqref}{\\href{###1}{(\\text{#1})}}',
8
+ '\\ref': '\\htmlClass{ktx-ref}{\\href{###1}{\\text{#1}}}',
9
+ '\\label': '\\htmlClass{ktx-label}{\\htmlId{#1}{}}'
10
+ }
11
+ });
12
+ function $(s, el = d) { return el.querySelector(s); }
13
+ function $$(s, el = d) { return el.querySelectorAll(s); }
14
+ const xrefs = $$('.katex:has(:is(.ktx-ref, .ktx-eqref))');
15
+ if (!xrefs.length) return;
16
+
17
+ const M = {}; // map equation labels to numbers
18
+ let n = 0;
19
+ // scan all display expressions for labels and tags
20
+ $$('.katex-display').forEach(el => {
21
+ const s = '.ktx-label > [id]', lab = $(s, el);
22
+ if (!lab) return; // no labels found
23
+ // find the common ancestor of all labels and the label of each row of equation
24
+ const ids = [...$$(':scope > [style]', lab.offsetParent.parentNode)].map(el => {
25
+ return $(s, el)?.id || '';
26
+ });
27
+ // find all tags
28
+ const tags = [...$$('.tag > .vlist-t > .vlist-r > .vlist > [style]', el)].map(tag => {
29
+ // if tag is automatically generated by CSS counter, we have to compute it
30
+ // manually because there is no way to access CSS counters from JS
31
+ return $('.eqn-num', tag) ? `(${++n})` : tag.innerText.trim();
32
+ });
33
+ if (ids.length === tags.length) {
34
+ ids.forEach((id, i) => id && (M[id] = tags[i]));
35
+ } else {
36
+ console.warn('labels and tags differ in length in ', el, ids, tags);
37
+ }
38
+ });
39
+
40
+ // resolve innerText of cross-ref links
41
+ function resolveRefLink(a, paren) {
42
+ const id = a.getAttribute('href').replace(/^#/, ''), tag = M[id];
43
+ a.innerText = tag ? (paren ? tag : tag.replace(/^\(|\)$/g, '')) : '???';
44
+ a.classList.add(`cross-ref-eq${paren ? 'n' : ''}`);
45
+ }
46
+ xrefs.forEach(el => {
47
+ const a = $('a', el);
48
+ if (!a) return;
49
+ const paren = a.parentNode.classList.contains('ktx-eqref'), p = el.parentNode;
50
+ p.after(a); p.remove(); // remove KaTeX's HTML for links to make their style consistent with surrounding text
51
+ resolveRefLink(a, paren);
52
+ });
53
+ })(document);
@@ -1 +1 @@
1
- renderMathInElement(document.body);
1
+ (e=>{function t(t,r=e){return r.querySelector(t)}function r(t,r=e){return r.querySelectorAll(t)}renderMathInElement(e.body,{strict:!1,throwOnError:!1,trust:e=>["\\href","\\htmlId","\\htmlClass"].includes(e.command),macros:{"\\eqref":"\\htmlClass{ktx-eqref}{\\href{###1}{(\\text{#1})}}","\\ref":"\\htmlClass{ktx-ref}{\\href{###1}{\\text{#1}}}","\\label":"\\htmlClass{ktx-label}{\\htmlId{#1}{}}"}});const n=r(".katex:has(:is(.ktx-ref, .ktx-eqref))");if(!n.length)return;const s={};let l=0;r(".katex-display").forEach((e=>{const n=".ktx-label > [id]",a=t(n,e);if(!a)return;const o=[...r(":scope > [style]",a.offsetParent.parentNode)].map((e=>t(n,e)?.id||"")),c=[...r(".tag > .vlist-t > .vlist-r > .vlist > [style]",e)].map((e=>t(".eqn-num",e)?`(${++l})`:e.innerText.trim()));o.length===c.length?o.forEach(((e,t)=>e&&(s[e]=c[t]))):console.warn("labels and tags differ in length in ",e,o,c)})),n.forEach((e=>{const r=t("a",e);if(!r)return;const n=r.parentNode.classList.contains("ktx-eqref"),l=e.parentNode;l.after(r),l.remove(),function(e,t){const r=e.getAttribute("href").replace(/^#/,""),n=s[r];e.innerText=n?t?n:n.replace(/^\(|\)$/g,""):"???",e.classList.add("cross-ref-eq"+(t?"n":""))}(r,n)}))})(document);
@@ -1 +1 @@
1
- {"version":3,"names":["renderMathInElement","document","body"],"sources":["render-katex.js"],"mappings":"AAAAA,oBAAoBC,SAASC","ignoreList":[]}
1
+ {"version":3,"names":["d","$","s","el","querySelector","$$","querySelectorAll","renderMathInElement","body","strict","throwOnError","trust","context","includes","command","macros","xrefs","length","M","n","forEach","lab","ids","offsetParent","parentNode","map","id","tags","tag","innerText","trim","i","console","warn","a","paren","classList","contains","p","after","remove","getAttribute","replace","add","resolveRefLink","document"],"sources":["render-katex.js"],"mappings":"AACA,CAACA,IAUC,SAASC,EAAEC,EAAGC,EAAKH,GAAK,OAAOG,EAAGC,cAAcF,EAAI,CACpD,SAASG,EAAGH,EAAGC,EAAKH,GAAK,OAAOG,EAAGG,iBAAiBJ,EAAI,CAVxDK,oBAAoBP,EAAEQ,KAAM,CAC1BC,QAAQ,EAAOC,cAAc,EAC7BC,MAAOC,GAAW,CAAC,SAAU,WAAY,eAAeC,SAASD,EAAQE,SACzEC,OAAQ,CACN,UAAW,qDACX,QAAS,iDACT,UAAW,4CAKf,MAAMC,EAAQX,EAAG,yCACjB,IAAKW,EAAMC,OAAQ,OAEnB,MAAMC,EAAI,CAAC,EACX,IAAIC,EAAI,EAERd,EAAG,kBAAkBe,SAAQjB,IAC3B,MAAMD,EAAI,oBAAqBmB,EAAMpB,EAAEC,EAAGC,GAC1C,IAAKkB,EAAK,OAEV,MAAMC,EAAM,IAAIjB,EAAG,mBAAoBgB,EAAIE,aAAaC,aAAaC,KAAItB,GAChEF,EAAEC,EAAGC,IAAKuB,IAAM,KAGnBC,EAAO,IAAItB,EAAG,gDAAiDF,IAAKsB,KAAIG,GAGrE3B,EAAE,WAAY2B,GAAO,MAAMT,KAAOS,EAAIC,UAAUC,SAErDR,EAAIL,SAAWU,EAAKV,OACtBK,EAAIF,SAAQ,CAACM,EAAIK,IAAML,IAAOR,EAAEQ,GAAMC,EAAKI,MAE3CC,QAAQC,KAAK,uCAAwC9B,EAAImB,EAAKK,EAChE,IASFX,EAAMI,SAAQjB,IACZ,MAAM+B,EAAIjC,EAAE,IAAKE,GACjB,IAAK+B,EAAG,OACR,MAAMC,EAAQD,EAAEV,WAAWY,UAAUC,SAAS,aAAcC,EAAInC,EAAGqB,WACnEc,EAAEC,MAAML,GAAII,EAAEE,SAThB,SAAwBN,EAAGC,GACzB,MAAMT,EAAKQ,EAAEO,aAAa,QAAQC,QAAQ,KAAM,IAAKd,EAAMV,EAAEQ,GAC7DQ,EAAEL,UAAYD,EAAOO,EAAQP,EAAMA,EAAIc,QAAQ,WAAY,IAAO,MAClER,EAAEE,UAAUO,IAAI,gBAAeR,EAAQ,IAAM,IAC/C,CAMES,CAAeV,EAAGC,EAAM,GAE3B,EAnDD,CAmDGU","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xiee/utils",
3
- "version": "1.13.35",
3
+ "version": "1.13.37",
4
4
  "description": "Miscellaneous tools and utilities to manipulate HTML pages",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"