@xiee/utils 1.10.0 → 1.10.1
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/.github/workflows/npm-publish.yml +2 -2
- package/README.md +2 -2
- package/css/snap.css +2 -2
- package/css/snap.min.css +1 -1
- package/js/number-captions.js +1 -1
- package/js/snap.js +1 -1
- package/js/snap.min.js +1 -1
- package/package.json +1 -1
|
@@ -6,8 +6,8 @@ jobs:
|
|
|
6
6
|
runs-on: ubuntu-latest
|
|
7
7
|
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
|
|
8
8
|
steps:
|
|
9
|
-
- uses: actions/checkout@
|
|
10
|
-
- uses: actions/setup-node@
|
|
9
|
+
- uses: actions/checkout@v4
|
|
10
|
+
- uses: actions/setup-node@v4
|
|
11
11
|
with:
|
|
12
12
|
registry-url: 'https://registry.npmjs.org'
|
|
13
13
|
- run: ./build.sh
|
package/README.md
CHANGED
|
@@ -128,8 +128,8 @@ This requires highlight.js to be loaded in advance.
|
|
|
128
128
|
|
|
129
129
|
## math-code.js
|
|
130
130
|
|
|
131
|
-
Write LaTeX math expressions (`$\alpha$`) in `<code></code
|
|
132
|
-
backticks in Markdown (which will be rendered to `<code>` in HTML), and this
|
|
131
|
+
Write LaTeX math expressions (`$\alpha$`) in `<code></code>` in HTML or a pair
|
|
132
|
+
of backticks in Markdown (which will be rendered to `<code>` in HTML), and this
|
|
133
133
|
script will remove the `<code>` tag, so that MathJax can recognize the math
|
|
134
134
|
expressions (by default, MathJax ignores math in `<code>`).
|
|
135
135
|
|
package/css/snap.css
CHANGED
|
@@ -59,7 +59,7 @@ a { color: #eb4a47; }
|
|
|
59
59
|
margin-bottom: 0.5em;
|
|
60
60
|
}
|
|
61
61
|
.mirrored { transform: scale(-1, 1); }
|
|
62
|
-
.timer {
|
|
62
|
+
.timer { opacity: 0; }
|
|
63
63
|
html:fullscreen::-webkit-scrollbar, .spacer { display: none; }
|
|
64
64
|
html:fullscreen {
|
|
65
65
|
-ms-overflow-style: none;
|
|
@@ -88,7 +88,7 @@ html:fullscreen {
|
|
|
88
88
|
}
|
|
89
89
|
li li { font-size: .9em; }
|
|
90
90
|
.slide-mode .spacer { display: block; }
|
|
91
|
-
.slide-mode .timer {
|
|
91
|
+
.slide-mode .timer { opacity: initial; }
|
|
92
92
|
}
|
|
93
93
|
@media (min-width: 1400px) {
|
|
94
94
|
:root { --slide-width: 33%; }
|
package/css/snap.min.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
:root{--slide-width:100%}html{scroll-snap-type:y mandatory}td,th{padding:.2em .5em}.slide{padding:0 1em}.frontmatter .main,.middle .main,.slide{display:flex;flex-direction:column}.slide>.main{flex-grow:1}.slide>.header{margin-bottom:1em}.slide h2,.slide h3{margin-top:unset}body{max-width:fit-content;padding:0}a{color:#eb4a47}:not(pre)>code{background-color:#fdfded}#TOC{columns:2}#TOC::before{font-size:1.3em;font-weight:700;display:block;border-bottom:1px solid #666}.frontmatter .main,.middle .main{justify-content:center}.footer{display:flex;justify-content:space-between;opacity:.5;font:.7em monospace}.inverse{background-color:#eee;filter:invert(1)}.fade{background:repeating-linear-gradient(135deg,#fff,#fff 30px,#ddd 32px,#ddd 32px);opacity:.6}.center{text-align:center}.slide-container h2 .section-number{display:inline-block;background-color:#666;color:#fff;padding:0 .1em;margin-right:.3em}.overview{font-size:.8em}.overview .slide-container{display:flex;flex-wrap:wrap;justify-content:space-evenly}.overview .slide-container .slide{width:var(--slide-width);border:1px dotted #ccc;margin-bottom:.5em}.mirrored{transform:scale(-1,1)}.timer{
|
|
1
|
+
:root{--slide-width:100%}html{scroll-snap-type:y mandatory}td,th{padding:.2em .5em}.slide{padding:0 1em}.frontmatter .main,.middle .main,.slide{display:flex;flex-direction:column}.slide>.main{flex-grow:1}.slide>.header{margin-bottom:1em}.slide h2,.slide h3{margin-top:unset}body{max-width:fit-content;padding:0}a{color:#eb4a47}:not(pre)>code{background-color:#fdfded}#TOC{columns:2}#TOC::before{font-size:1.3em;font-weight:700;display:block;border-bottom:1px solid #666}.frontmatter .main,.middle .main{justify-content:center}.footer{display:flex;justify-content:space-between;opacity:.5;font:.7em monospace}.inverse{background-color:#eee;filter:invert(1)}.fade{background:repeating-linear-gradient(135deg,#fff,#fff 30px,#ddd 32px,#ddd 32px);opacity:.6}.center{text-align:center}.slide-container h2 .section-number{display:inline-block;background-color:#666;color:#fff;padding:0 .1em;margin-right:.3em}.overview{font-size:.8em}.overview .slide-container{display:flex;flex-wrap:wrap;justify-content:space-evenly}.overview .slide-container .slide{width:var(--slide-width);border:1px dotted #ccc;margin-bottom:.5em}.mirrored{transform:scale(-1,1)}.timer{opacity:0}.spacer,html:fullscreen::-webkit-scrollbar{display:none}html:fullscreen{-ms-overflow-style:none;scrollbar-width:none}@media screen and (min-width:992px){:root{--slide-width:49%;--slide-scale:1;--slide-ratio:0.75;--slide-top:auto}.slide-mode{font-size:2em;background-color:#d7d8d2;scale:var(--slide-scale);margin-top:var(--slide-top)}.slide-mode .slide{min-height:calc(100vh / var(--slide-scale));width:calc(100vh / var(--slide-ratio)/ var(--slide-scale));box-shadow:0 0 2em #888;clip-path:inset(0 -2em 0 -2em);background-color:#fff;scroll-snap-align:start}li li{font-size:.9em}.slide-mode .spacer{display:block}.slide-mode .timer{opacity:initial}}@media (min-width:1400px){:root{--slide-width:33%}}@media (min-width:1800px){:root{--slide-width:24.67%}}
|
package/js/number-captions.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// config options via data-foo attributes of this <script>:
|
|
4
4
|
// * data-colon: the colon character (':' by default);
|
|
5
5
|
// * data-fig-label: label for figure captions ('Figure ' by default)
|
|
6
|
-
// * data-tab-label:
|
|
6
|
+
// * data-tab-label: label for table captions ('Table ' by default)
|
|
7
7
|
(d => {
|
|
8
8
|
const cfg = d.currentScript?.dataset, colon = cfg?.colon || ':';
|
|
9
9
|
function NUM(target, label) {
|
package/js/snap.js
CHANGED
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
const t2 = new Date(Math.abs(t)).toISOString().substr(11, 8).replace(/^00:/, '');
|
|
134
134
|
tms.forEach(el => {
|
|
135
135
|
el.innerText = t2;
|
|
136
|
-
if (t < 0) el.style.
|
|
136
|
+
if (t < 0) el.style.opacity = Math.ceiling(t/1000) % 2;
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
139
|
function toggleView(e) {
|
package/js/snap.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e){let t=e.body;const n=":scope > h2";function o(e,n=1){if(t.querySelectorAll(e).length>=n)return!0;for(let o=0;o<t.children.length;o++)if(t.children[o].querySelectorAll(e).length>=n){t=t.children[o];break}return!1}function r(t,n){const o=e.createElement(t);return n&&(o.className=n),o}if(!o(":scope > hr:not([class])",3)&&"BODY"===t.tagName){if(!o(n)&&"BODY"===t.tagName)return;t.querySelectorAll(n).forEach((e=>e.before(r("hr"))))}function i(e){return""===e?.innerText?e:r("div","slide")}function s(e){return"HR"===e.tagName&&0===e.attributes.length}t.classList.add("slide-container"),[".frontmatter","#TOC"].forEach((t=>{const n=e.body.querySelector(t);if(n)if(".frontmatter"===t)n.classList.add("slide");else{const e=i();n.before(e),e.append(n)}}));let l=t.firstElementChild;if(s(l)&&l.remove(),l=t.firstElementChild,!l)return;let c=i();for(l.before(c);;){let e=c.nextSibling;if(!e)break;s(e)?(c=i(c),e.before(c),e.remove()):e.classList?.contains("slide")?(c=i(c),e.after(c)):c.append(e)}function a(e,t){const n=r("div");n.innerHTML=`<div ${t}></div>`;const o=n.firstElementChild.attributes;for(const t of o)e.setAttribute(t.name,t.value);n.remove()}function d(e){setTimeout((()=>e?.scrollIntoView()),100)}const f=e.documentElement,u=e.body.classList,h=e.querySelectorAll("div.slide"),m=h.length,p=e.querySelector("span.timer"),y=e.querySelector(".footnotes");h.forEach(((e,t)=>{const n=r("div","header"),o=r("div","main"),i=r("div","footer");o.append(...e.childNodes),e.append(o),e.insertAdjacentElement("afterbegin",n),e.insertAdjacentElement("beforeend",i),y&&e.querySelectorAll('.footnote-ref > a[href^="#fn"]').forEach((t=>{const n=y.querySelector("li"+t.getAttribute("href"));if(!n)return;let o=e.querySelector("section.footnotes");o||(o=r("section","footnotes"),i.before(o)),o.append(n),n.firstElementChild?.insertAdjacentHTML("afterbegin",`[${t.innerHTML}] `),n.outerHTML=n.innerHTML})),i.append(p?p.cloneNode():r("span","timer"));const s=r("span","page-number");s.innerText=t+1+"/"+m,s.onclick=e=>location.hash=t+1,i.append(s);for(const t of o.childNodes){if(t.nodeType!==Node.COMMENT_NODE)continue;let n=t.textContent;if(!/^#/.test(n))continue;n=n.replace(/^#/,"");const o=/[\s\n]class="([^"]+)"/,r=n.match(o);r&&(n=n.replace(o,"").trim(),e.className+=" "+r[1]),n&&a(e,n);break}e.addEventListener("click",(e=>{e.altKey&&(q(e),d(e.target))}))})),[...e.querySelectorAll("a.footnote-backref"),y,p].forEach((e=>e?.remove()));const g=e.querySelectorAll("span.timer"),b=1e3*g[0].dataset.total;let v;function E(){v=new Date,setInterval(S,1e3)}function S(){if(!u.contains("slide-mode"))return;let e=new Date-v;b&&(e=b-e);const t=new Date(Math.abs(e)).toISOString().substr(11,8).replace(/^00:/,"");g.forEach((n=>{n.innerText=t,e<0&&(n.style.
|
|
1
|
+
!function(e){let t=e.body;const n=":scope > h2";function o(e,n=1){if(t.querySelectorAll(e).length>=n)return!0;for(let o=0;o<t.children.length;o++)if(t.children[o].querySelectorAll(e).length>=n){t=t.children[o];break}return!1}function r(t,n){const o=e.createElement(t);return n&&(o.className=n),o}if(!o(":scope > hr:not([class])",3)&&"BODY"===t.tagName){if(!o(n)&&"BODY"===t.tagName)return;t.querySelectorAll(n).forEach((e=>e.before(r("hr"))))}function i(e){return""===e?.innerText?e:r("div","slide")}function s(e){return"HR"===e.tagName&&0===e.attributes.length}t.classList.add("slide-container"),[".frontmatter","#TOC"].forEach((t=>{const n=e.body.querySelector(t);if(n)if(".frontmatter"===t)n.classList.add("slide");else{const e=i();n.before(e),e.append(n)}}));let l=t.firstElementChild;if(s(l)&&l.remove(),l=t.firstElementChild,!l)return;let c=i();for(l.before(c);;){let e=c.nextSibling;if(!e)break;s(e)?(c=i(c),e.before(c),e.remove()):e.classList?.contains("slide")?(c=i(c),e.after(c)):c.append(e)}function a(e,t){const n=r("div");n.innerHTML=`<div ${t}></div>`;const o=n.firstElementChild.attributes;for(const t of o)e.setAttribute(t.name,t.value);n.remove()}function d(e){setTimeout((()=>e?.scrollIntoView()),100)}const f=e.documentElement,u=e.body.classList,h=e.querySelectorAll("div.slide"),m=h.length,p=e.querySelector("span.timer"),y=e.querySelector(".footnotes");h.forEach(((e,t)=>{const n=r("div","header"),o=r("div","main"),i=r("div","footer");o.append(...e.childNodes),e.append(o),e.insertAdjacentElement("afterbegin",n),e.insertAdjacentElement("beforeend",i),y&&e.querySelectorAll('.footnote-ref > a[href^="#fn"]').forEach((t=>{const n=y.querySelector("li"+t.getAttribute("href"));if(!n)return;let o=e.querySelector("section.footnotes");o||(o=r("section","footnotes"),i.before(o)),o.append(n),n.firstElementChild?.insertAdjacentHTML("afterbegin",`[${t.innerHTML}] `),n.outerHTML=n.innerHTML})),i.append(p?p.cloneNode():r("span","timer"));const s=r("span","page-number");s.innerText=t+1+"/"+m,s.onclick=e=>location.hash=t+1,i.append(s);for(const t of o.childNodes){if(t.nodeType!==Node.COMMENT_NODE)continue;let n=t.textContent;if(!/^#/.test(n))continue;n=n.replace(/^#/,"");const o=/[\s\n]class="([^"]+)"/,r=n.match(o);r&&(n=n.replace(o,"").trim(),e.className+=" "+r[1]),n&&a(e,n);break}e.addEventListener("click",(e=>{e.altKey&&(q(e),d(e.target))}))})),[...e.querySelectorAll("a.footnote-backref"),y,p].forEach((e=>e?.remove()));const g=e.querySelectorAll("span.timer"),b=1e3*g[0].dataset.total;let v;function E(){v=new Date,setInterval(S,1e3)}function S(){if(!u.contains("slide-mode"))return;let e=new Date-v;b&&(e=b-e);const t=new Date(Math.abs(e)).toISOString().substr(11,8).replace(/^00:/,"");g.forEach((n=>{n.innerText=t,e<0&&(n.style.opacity=Math.ceiling(e/1e3)%2)}))}function q(e){u.toggle("overview")?u.remove("slide-mode"):N(e)}e.addEventListener("keyup",(t=>{t.target===e.body&&("f"===t.key&&f.requestFullscreen(),"o"===t.key&&q(t),"m"===t.key&&u.toggle("mirrored"),sessionStorage.setItem("body-class",e.body.className))})),e.onfullscreenchange=t=>{e.fullscreenElement&&(!v&&E(),N(t))},g.forEach((e=>e.addEventListener("click",(e=>E()))));let L=-1;function T(){if(L>=0)return L;const e=r("div","slide");return t.querySelector(".slide:last-of-type").after(e),L=e.offsetHeight,e.remove(),L}const w=r("style");w.setAttribute("type","text/css"),e.head.append(w),w.innerHTML=`:root{--slide-ratio:${screen.height/screen.width}}`;const A=+getComputedStyle(f).getPropertyValue("--slide-ratio");function N(t){if("load"===t.type&&d(h[location.hash.replace(/^#/,"")-1]),u.contains("overview"))return;let n=window.innerHeight,o=n/900,i=n/window.innerWidth,s=e.fullscreenElement;u.toggle("slide-mode",s||i<=A)&&!s&&f.scrollWidth>f.offsetWidth&&u.remove("slide-mode"),w.innerHTML=`:root{--slide-ratio:${A};--slide-scale:${o};--slide-top:${(o-1)/2*e.body.scrollHeight+"px"};}`,!e.querySelector(".spacer.fade")&&u.contains("slide-mode")&&h.forEach((e=>{const t=r("div","spacer fade"),n=e.offsetHeight,i=T();e.append(t),n<=i||(t.style.height=(i-n%i)*o+"px")}))}["load","resize"].forEach((e=>window.addEventListener(e,N)));const H=sessionStorage.getItem("body-class");H&&(e.body.className+=" "+H)}(document);
|