@xiee/utils 1.12.28 → 1.12.29

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
@@ -6,7 +6,7 @@ body {
6
6
  line-height: 1.5;
7
7
  box-sizing: border-box;
8
8
  }
9
- body, .footnotes, .abstract, code { font-size: .9em; }
9
+ body, .abstract, code, .footnotes, #refs { font-size: .9em; }
10
10
  li li { font-size: .95em; }
11
11
  ul:has(li > input[type="checkbox"]) { list-style: none; padding-left: 1em; }
12
12
  *, *:before, *:after { box-sizing: inherit; }
@@ -59,7 +59,16 @@ table, .body h2 { border-bottom: 1px solid #666; }
59
59
  .cross-ref-sec::before { content: "Section "; }
60
60
  .cross-ref-fig::before, .ref-number-fig::before { content: "Figure "; }
61
61
  .cross-ref-tab::before, .ref-number-tab::before { content: "Table "; }
62
- .abstract::before { content: "Abstract"; display: block; margin: 1em auto; text-align: center; font-weight: bold; }
62
+ .abstract, #refs {
63
+ &::before { display: block; margin: 1em auto; font-weight: bold; }
64
+ }
65
+ .abstract::before { content: "Abstract"; text-align: center; }
66
+ #refs::before { content: "Bibliography"; font-size: 1.5em; }
67
+ .ref-paren-open::before { content: "("; }
68
+ .ref-paren-close::after { content: ")"; }
69
+ .ref-semi-colon::after { content: "; "; }
70
+ .ref-and::after { content: " and "; }
71
+ .ref-et-al::after { content: " et al."; font-style: italic; }
63
72
  .footnote-ref a {
64
73
  &::before { content: "["; }
65
74
  &::after { content: "]"; }
@@ -1,2 +1,2 @@
1
- body{box-sizing:border-box;max-width:800px;margin:auto;padding:1em;font-family:sans-serif;line-height:1.5}body,.footnotes,.abstract,code{font-size:.9em}li li{font-size:.95em}ul:has(li>input[type=checkbox]){padding-left:1em;list-style:none}*,:before,:after{box-sizing:inherit}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}}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:before{content:"Abstract";text-align:center;margin:1em auto;font-weight:700;display:block}.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%;font-size:12pt}tr,img{page-break-inside:avoid}}@media only screen and (width>=992px){pre{white-space:pre}}
1
+ body{box-sizing:border-box;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:inherit}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}}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-semi-colon: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%;font-size:12pt}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,0GAQA,8CACA,sBACA,iEACA,oCACA,gBACA,uBACA,wDACA,mDACA,2FACA,6DACA,8FACA,kCACA,qDACA,mDACA,yCACA,oEAIE,yBAEF,kBACA,0EACA,+DACA,+DACA,qCACA,4CAEE,wCACA,sBACA,oDAEF,2EAMA,4CACA,+BACA,8BAEE,qBACA,uBAEF,4CACA,wDACA,+BACA,wDACA,yCACA,yCACA,+DACA,8DACA,oGACA,gBACE,qBACA,qBAEF,iCAEE,kDAGF,aACE,mCACA,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 box-sizing: border-box;\n}\nbody, .footnotes, .abstract, code { 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: inherit; }\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}\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::before { content: \"Abstract\"; display: block; margin: 1em auto; text-align: center; font-weight: bold; }\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 { font-size: 12pt; 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,0GAQA,oDACA,sBACA,iEACA,oCACA,gBACA,uBACA,wDACA,mDACA,2FACA,6DACA,8FACA,kCACA,qDACA,mDACA,yCACA,oEAIE,yBAEF,kBACA,0EACA,+DACA,+DACA,qCACA,4CAEE,wCACA,sBACA,oDAEF,2EAMA,4CACA,+BACA,8BAEE,qBACA,uBAEF,4CACA,wDACA,+BACA,wDACA,yCACA,yCACA,+DACA,8DACA,gBACE,wDAEF,sDACA,oDACA,mCACA,mCACA,mCACA,+BACA,qDACA,gBACE,qBACA,qBAEF,iCAEE,kDAGF,aACE,mCACA,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 box-sizing: border-box;\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: inherit; }\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}\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-semi-colon::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 { font-size: 12pt; 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":[]}
package/js/sidenotes.js CHANGED
@@ -1,32 +1,32 @@
1
1
  // move footnotes (ids start with fn) and citations (ids start with ref-) to sidenotes
2
2
  (d => {
3
- d.querySelectorAll('.footnotes > ol > li[id^="fn"], #refs > div[id^="ref-"]').forEach(el => {
3
+ d.querySelectorAll('.footnotes > ol > li[id^="fn"], #refs > *[id^="ref-"]').forEach(el => {
4
4
  // find <a> that points to note id in body
5
- const h = `a[href="#${el.id}"]`,
6
- a = d.querySelector(`${h} > sup, sup > ${h}, .citation > ${h}`);
7
- if (!a) return;
8
- const a2 = a.parentNode;
9
- (a.tagName === 'A' ? a : a2).removeAttribute('href');
10
- const s = d.createElement('div'); // insert a side div next to a2 in body
11
- s.className = 'side side-right';
12
- if (/^fn/.test(el.id)) {
13
- s.innerHTML = el.innerHTML;
14
- // add footnote number
15
- s.firstElementChild.insertAdjacentHTML('afterbegin', `<span class="bg-number">${a.innerText}</span> `);
16
- s.querySelector('a[href^="#fnref"]')?.remove(); // remove backreference
17
- s.className += ' footnotes';
18
- } else {
19
- s.innerHTML = el.outerHTML;
20
- }
21
- while (s.lastChild?.nodeName === '#text' && /^\s*$/.test(s.lastChild.textContent)) {
22
- s.lastChild.remove();
23
- }
24
- // remove fullwidth classes if present (because they cannot be used in the margin)
25
- s.querySelectorAll('.fullwidth').forEach(el => el.classList.remove('fullwidth'));
26
- // insert note after the <sup> or <span> that contains a
27
- a2.after(s);
28
- a2.classList.add('note-ref');
29
- el.remove();
5
+ const h = `a[href="#${el.id}"]`;
6
+ d.querySelectorAll(`${h} > sup, sup > ${h}, .citation > ${h}`).forEach(a => {
7
+ const a2 = a.parentNode;
8
+ (a.tagName === 'A' ? a : a2).removeAttribute('href');
9
+ const s = d.createElement('div'); // insert a side div next to a2 in body
10
+ s.className = 'side side-right';
11
+ if (/^fn/.test(el.id)) {
12
+ s.innerHTML = el.innerHTML;
13
+ // add footnote number
14
+ s.firstElementChild.insertAdjacentHTML('afterbegin', `<span class="bg-number">${a.innerText}</span> `);
15
+ s.querySelector('a[href^="#fnref"]')?.remove(); // remove backreference
16
+ s.className += ' footnotes';
17
+ } else {
18
+ s.innerHTML = el.outerHTML;
19
+ }
20
+ while (s.lastChild?.nodeName === '#text' && /^\s*$/.test(s.lastChild.textContent)) {
21
+ s.lastChild.remove();
22
+ }
23
+ // remove fullwidth classes if present (because they cannot be used in the margin)
24
+ s.querySelectorAll('.fullwidth').forEach(el => el.classList.remove('fullwidth'));
25
+ // insert note after the <sup> or <span> that contains a
26
+ a2.after(s);
27
+ a2.classList.add('note-ref');
28
+ el.remove();
29
+ });
30
30
  });
31
31
  // remove the footnote/citation section if it's empty now
32
32
  d.querySelectorAll('.footnotes, #refs').forEach(el => {
@@ -1 +1 @@
1
- (e=>{e.querySelectorAll('.footnotes > ol > li[id^="fn"], #refs > div[id^="ref-"]').forEach((t=>{const s=`a[href="#${t.id}"]`,r=e.querySelector(`${s} > sup, sup > ${s}, .citation > ${s}`);if(!r)return;const o=r.parentNode;("A"===r.tagName?r:o).removeAttribute("href");const l=e.createElement("div");for(l.className="side side-right",/^fn/.test(t.id)?(l.innerHTML=t.innerHTML,l.firstElementChild.insertAdjacentHTML("afterbegin",`<span class="bg-number">${r.innerText}</span> `),l.querySelector('a[href^="#fnref"]')?.remove(),l.className+=" footnotes"):l.innerHTML=t.outerHTML;"#text"===l.lastChild?.nodeName&&/^\s*$/.test(l.lastChild.textContent);)l.lastChild.remove();l.querySelectorAll(".fullwidth").forEach((e=>e.classList.remove("fullwidth"))),o.after(l),o.classList.add("note-ref"),t.remove()})),e.querySelectorAll(".footnotes, #refs").forEach((e=>{/^\s*$/.test(e.innerText)&&e.remove()})),e.getElementById("TOC")?.classList.add("side","side-left");const t=e.querySelectorAll(".side.side-right, .side.side-left"),s=[];e.querySelectorAll(".fullwidth").forEach((e=>{s.push([e,e.getBoundingClientRect()])})),t.length&&e.body.classList.add("has-sidenotes"),t.forEach((e=>{const t=e.getBoundingClientRect();for(let e of s){const s=e[1];t.right<s.left||t.left>s.right||t.bottom<s.top||t.top>s.bottom||e[0].classList.remove("fullwidth")}}))})(document);
1
+ (e=>{e.querySelectorAll('.footnotes > ol > li[id^="fn"], #refs > *[id^="ref-"]').forEach((t=>{const s=`a[href="#${t.id}"]`;e.querySelectorAll(`${s} > sup, sup > ${s}, .citation > ${s}`).forEach((s=>{const o=s.parentNode;("A"===s.tagName?s:o).removeAttribute("href");const l=e.createElement("div");for(l.className="side side-right",/^fn/.test(t.id)?(l.innerHTML=t.innerHTML,l.firstElementChild.insertAdjacentHTML("afterbegin",`<span class="bg-number">${s.innerText}</span> `),l.querySelector('a[href^="#fnref"]')?.remove(),l.className+=" footnotes"):l.innerHTML=t.outerHTML;"#text"===l.lastChild?.nodeName&&/^\s*$/.test(l.lastChild.textContent);)l.lastChild.remove();l.querySelectorAll(".fullwidth").forEach((e=>e.classList.remove("fullwidth"))),o.after(l),o.classList.add("note-ref"),t.remove()}))})),e.querySelectorAll(".footnotes, #refs").forEach((e=>{/^\s*$/.test(e.innerText)&&e.remove()})),e.getElementById("TOC")?.classList.add("side","side-left");const t=e.querySelectorAll(".side.side-right, .side.side-left"),s=[];e.querySelectorAll(".fullwidth").forEach((e=>{s.push([e,e.getBoundingClientRect()])})),t.length&&e.body.classList.add("has-sidenotes"),t.forEach((e=>{const t=e.getBoundingClientRect();for(let e of s){const s=e[1];t.right<s.left||t.left>s.right||t.bottom<s.top||t.top>s.bottom||e[0].classList.remove("fullwidth")}}))})(document);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xiee/utils",
3
- "version": "1.12.28",
3
+ "version": "1.12.29",
4
4
  "description": "Miscellaneous tools and utilities to manipulate HTML pages",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"