@xiee/utils 1.5.1 → 1.5.3

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.
@@ -26,6 +26,7 @@
26
26
  function setText() {
27
27
  btn.innerText = status ? l2 : l1;
28
28
  }
29
+ setText();
29
30
  btn.onclick = (e) => {
30
31
  status = !status;
31
32
  d.querySelectorAll(`details.${cls}`).forEach(el => {
@@ -1 +1 @@
1
- (e=>{const t=e.currentScript?.dataset,a="folder";let n=!!t?.open;if(e.querySelectorAll(t?.selector||"pre>code[class],pre[class]").forEach((r=>{const l=e.createElement("details"),o=e.createElement("summary");l.className=a,l.open=n,o.innerText=(t?.label||"Details")+(t?.tagName?` <${r.tagName}>`:""),"CODE"===r.tagName&&"PRE"===r.parentNode.tagName&&(r=r.parentNode),l.append(o),r.before(l),l.append(r)})),!t?.hasOwnProperty("button"))return;const r=e.querySelector(t.parent);let l=e.querySelector(t.button);if(!l&&!r)return;l||(l=e.createElement("button"),l.id="toggle-all",r.insertAdjacentElement(t.position||"afterbegin",l));const o=t.buttonLabel||"Show Details",c=t.buttonLabel2||"Hide Details";l.onclick=t=>{n=!n,e.querySelectorAll(`details.${a}`).forEach((e=>{e.open=n})),l.innerText=n?c:o}})(document);
1
+ (e=>{const t=e.currentScript?.dataset,a="folder";let n=!!t?.open;if(e.querySelectorAll(t?.selector||"pre>code[class],pre[class]").forEach((r=>{const l=e.createElement("details"),o=e.createElement("summary");l.className=a,l.open=n,o.innerText=(t?.label||"Details")+(t?.tagName?` <${r.tagName}>`:""),"CODE"===r.tagName&&"PRE"===r.parentNode.tagName&&(r=r.parentNode),l.append(o),r.before(l),l.append(r)})),!t?.hasOwnProperty("button"))return;const r=e.querySelector(t.parent);let l=e.querySelector(t.button);if(!l&&!r)return;l||(l=e.createElement("button"),l.id="toggle-all",r.insertAdjacentElement(t.position||"afterbegin",l));const o=t.buttonLabel||"Show Details",c=t.buttonLabel2||"Hide Details";function s(){l.innerText=n?c:o}s(),l.onclick=t=>{n=!n,e.querySelectorAll(`details.${a}`).forEach((e=>{e.open=n})),s()}})(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((r=>{t||(t=e.querySelector(r))}));const r=t.querySelectorAll([1,2,3,4,5,6].map((e=>`:scope > h${e}`)).join(","));if(0===r.length)return;let n,i,l=e.getElementById("TOC");l?l.innerHTML="":(l=e.createElement("div"),l.id="TOC");let a,d=l,o=0;if(r.forEach((t=>{if(a=parseInt(t.tagName.replace(/^h/i,"")),n=e.createElement("li"),a>o)i=e.createElement("ul"),i.appendChild(n),d.appendChild(i);else if(a<o)for(let e=0;e<o-a;e++)d=d.parentNode.parentNode;a<=o&&d.parentNode.appendChild(n),d=n;const r=e.createElement("a");if(r.innerHTML=t.innerHTML,t.id)r.href="#"+t.id;else{const e=t.parentNode;e.classList.contains("section")&&e.id&&(r.href="#"+e.id)}d.appendChild(r),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);
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xiee/utils",
3
- "version": "1.5.1",
3
+ "version": "1.5.3",
4
4
  "description": "Miscellaneous tools and utilities to manipulate HTML pages",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"