@xiee/utils 1.5.2 → 1.5.4
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/js/load-typekit.js +1 -1
- package/js/load-typekit.min.js +1 -1
- package/js/toc.js +2 -2
- package/js/toc.min.js +1 -1
- package/package.json +1 -1
package/js/load-typekit.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
context.font = "72px monospace";
|
|
6
6
|
const size = context.measureText(text).width;
|
|
7
7
|
for (let font of [' SC', ' CN', ' TC', ' TW', '']) {
|
|
8
|
-
context.font = `72px 'Source Han Serif
|
|
8
|
+
context.font = `72px 'Source Han Serif${font}', monospace`;
|
|
9
9
|
// no need to load TypeKit if Source Hans Serif has been installed
|
|
10
10
|
if (context.measureText(text).width != size) return;
|
|
11
11
|
}
|
package/js/load-typekit.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(e=>{const t=e.createElement("canvas").getContext("2d"),a="abcdefghijklmnopqrstuvwxyz0123456789";t.font="72px monospace";const n=t.measureText(a).width;for(let e of[" SC"," CN"," TC"," TW",""])if(t.font=`72px 'Source Han Serif
|
|
1
|
+
(e=>{const t=e.createElement("canvas").getContext("2d"),a="abcdefghijklmnopqrstuvwxyz0123456789";t.font="72px monospace";const n=t.measureText(a).width;for(let e of[" SC"," CN"," TC"," TW",""])if(t.font=`72px 'Source Han Serif${e}', monospace`,t.measureText(a).width!=n)return;let o,c={kitId:"kwz5xar",scriptTimeout:3e3,async:!0},s=e.documentElement,i=setTimeout((function(){s.className=s.className.replace(/\bwf-loading\b/g,"")+" wf-inactive"}),c.scriptTimeout),r=e.createElement("script"),m=!1,l=e.getElementsByTagName("script")[0];s.className+=" wf-loading",r.src="https://use.typekit.net/"+c.kitId+".js",r.async=!0,r.onload=r.onreadystatechange=function(){if(o=this.readyState,!(m||o&&"complete"!=o&&"loaded"!=o)){m=!0,clearTimeout(i);try{Typekit.load(c)}catch(e){}}},l.parentNode.insertBefore(r,l)})(document);
|
package/js/toc.js
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
(d => {
|
|
3
3
|
// find the body of the article
|
|
4
4
|
let b;
|
|
5
|
-
['.article', '.body', 'article', 'body'].forEach(s => {
|
|
5
|
+
['.article', '.body', 'article', '.main', 'body'].forEach(s => {
|
|
6
6
|
if (!b) b = d.querySelector(s);
|
|
7
7
|
});
|
|
8
8
|
const hs = b.querySelectorAll([1, 2, 3, 4, 5, 6].map(i => `:scope > h${i}`).join(','));
|
|
9
9
|
if (hs.length === 0) return;
|
|
10
10
|
|
|
11
|
-
let toc = d.getElementById('TOC');
|
|
11
|
+
let toc = d.getElementById('TOC') || d.getElementById('TableOfContents');
|
|
12
12
|
if (toc) {
|
|
13
13
|
toc.innerHTML = ''; // empty and rebuild TOC if it has been generated (e.g., by Pandoc)
|
|
14
14
|
} else {
|
package/js/toc.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(e=>{let t;[".article",".body","article","body"].forEach((
|
|
1
|
+
(e=>{let t;[".article",".body","article",".main","body"].forEach((n=>{t||(t=e.querySelector(n))}));const n=t.querySelectorAll([1,2,3,4,5,6].map((e=>`:scope > h${e}`)).join(","));if(0===n.length)return;let r,i,l=e.getElementById("TOC")||e.getElementById("TableOfContents");l?l.innerHTML="":(l=e.createElement("div"),l.id="TOC");let a,d=l,o=0;if(n.forEach((t=>{if(a=parseInt(t.tagName.replace(/^h/i,"")),r=e.createElement("li"),a>o)i=e.createElement("ul"),i.appendChild(r),d.appendChild(i);else if(a<o)for(let e=0;e<o-a;e++)d=d.parentNode.parentNode;a<=o&&d.parentNode.appendChild(r),d=r;const n=e.createElement("a");if(n.innerHTML=t.innerHTML,t.id)n.href="#"+t.id;else{const e=t.parentNode;e.classList.contains("section")&&e.id&&(n.href="#"+e.id)}d.appendChild(n),o=a})),!l.parentNode){const e=t.querySelector("header");e?e.after(l):t.insertBefore(l,t.firstChild)}l.querySelector("span.section-number")&&l.firstElementChild.classList.add("numbered")})(document);
|