@xiee/utils 1.6.2 → 1.6.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.
@@ -1,7 +1,9 @@
1
1
  (d => {
2
2
  // add [] to footnote numbers
3
3
  d.querySelectorAll('sup[id^="fnref:"] > a.footnote-ref, a.footnote-ref > sup').forEach(el => {
4
- if (/^[0-9]+$/.test(el.innerText)) el.innerText = ' [' + el.innerText + ']';
4
+ if (!/^[0-9]+$/.test(el.innerText)) return;
5
+ el.innerText = `[${el.innerText}]`;
6
+ el.before(d.createTextNode(' '));
5
7
  });
6
8
  // move the return symbol into the previous <p>
7
9
  d.querySelectorAll('.footnotes > ol > li > p ~ .footnote-return').forEach(el => {
@@ -1 +1 @@
1
- (e=>{e.querySelectorAll('sup[id^="fnref:"] > a.footnote-ref, a.footnote-ref > sup').forEach((e=>{/^[0-9]+$/.test(e.innerText)&&(e.innerText=" ["+e.innerText+"]")})),e.querySelectorAll(".footnotes > ol > li > p ~ .footnote-return").forEach((e=>{e.previousElementSibling.lastChild.after(e)}))})(document);
1
+ (e=>{e.querySelectorAll('sup[id^="fnref:"] > a.footnote-ref, a.footnote-ref > sup').forEach((t=>{/^[0-9]+$/.test(t.innerText)&&(t.innerText=`[${t.innerText}]`,t.before(e.createTextNode(" ")))})),e.querySelectorAll(".footnotes > ol > li > p ~ .footnote-return").forEach((e=>{e.previousElementSibling.lastChild.after(e)}))})(document);
package/js/tabsets.js CHANGED
@@ -23,6 +23,7 @@ document.querySelectorAll('.tabset').forEach(h => {
23
23
  const l2 = newEl('div', 'tab-link');
24
24
  l2.append(l);
25
25
  l.outerHTML = l.innerHTML;
26
+ if (/<!--active-->/.test(l2.innerHTML)) l2.classList.add('active');
26
27
  el.before(l2);
27
28
  const p = newEl('div', 'tab-pane');
28
29
  l2.after(p);
package/js/tabsets.min.js CHANGED
@@ -1 +1 @@
1
- document.querySelectorAll(".tabset").forEach((e=>{const t=[...e.querySelectorAll(":scope > .tab-link")],n=[...e.querySelectorAll(":scope > .tab-pane")];function a(e){function a(e,t){e.forEach(((e,n)=>e.classList[n===t?"add":"remove"]("active")))}a(t,e),a(n,e)}function r(e,t){const n=document.createElement(e);return n.className=t,n}let c,i=-1,o=e.nextElementSibling;if(0===t.length&&"UL"===o.tagName&&([...o.children].forEach((e=>{const a=e.firstElementChild;if(!a)return;const c=r("div","tab-link");c.append(a),a.outerHTML=a.innerHTML,o.before(c);const i=r("div","tab-pane");c.after(i),[...e.children].forEach((e=>i.append(e))),t.push(c),n.push(i)})),o.remove()),0===t.length)for(;o&&("#comment"!==o.nodeName||o.nodeValue.trim()!==`tabset:${e.id}`);){const e=o.tagName;if(/^H[1-6]$/.test(e)){const a=+e.replace("H","");if(a<=i)break;if(i<0&&(i=a-1),a===i+1){c=r("div","tab-pane"),o.after(c),o.classList.add("tab-link"),o.querySelector(".anchor")?.remove(),o.outerHTML=o.outerHTML.replace(/^<h[1-6](.*)h[1-6]>$/,"<div$1div>"),o=c.previousElementSibling,t.push(o),n.push(c),o=c.nextSibling;continue}}c&&(c.append(o),o=c),o=o.nextSibling}""==e.innerText.trim()&&(t.forEach((t=>e.append(t))),n.forEach((t=>e.append(t))));let l=0;t.forEach(((e,n)=>{n>0&&t[n-1].after(e),e.onclick=()=>a(n),e.classList.contains("active")&&(l=n)})),a(l)}));
1
+ document.querySelectorAll(".tabset").forEach((e=>{const t=[...e.querySelectorAll(":scope > .tab-link")],n=[...e.querySelectorAll(":scope > .tab-pane")];function a(e){function a(e,t){e.forEach(((e,n)=>e.classList[n===t?"add":"remove"]("active")))}a(t,e),a(n,e)}function i(e,t){const n=document.createElement(e);return n.className=t,n}let c,r=-1,o=e.nextElementSibling;if(0===t.length&&"UL"===o.tagName&&([...o.children].forEach((e=>{const a=e.firstElementChild;if(!a)return;const c=i("div","tab-link");c.append(a),a.outerHTML=a.innerHTML,/<!--active-->/.test(c.innerHTML)&&c.classList.add("active"),o.before(c);const r=i("div","tab-pane");c.after(r),[...e.children].forEach((e=>r.append(e))),t.push(c),n.push(r)})),o.remove()),0===t.length)for(;o&&("#comment"!==o.nodeName||o.nodeValue.trim()!==`tabset:${e.id}`);){const e=o.tagName;if(/^H[1-6]$/.test(e)){const a=+e.replace("H","");if(a<=r)break;if(r<0&&(r=a-1),a===r+1){c=i("div","tab-pane"),o.after(c),o.classList.add("tab-link"),o.querySelector(".anchor")?.remove(),o.outerHTML=o.outerHTML.replace(/^<h[1-6](.*)h[1-6]>$/,"<div$1div>"),o=c.previousElementSibling,t.push(o),n.push(c),o=c.nextSibling;continue}}c&&(c.append(o),o=c),o=o.nextSibling}""==e.innerText.trim()&&(t.forEach((t=>e.append(t))),n.forEach((t=>e.append(t))));let l=0;t.forEach(((e,n)=>{n>0&&t[n-1].after(e),e.onclick=()=>a(n),e.classList.contains("active")&&(l=n)})),a(l)}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xiee/utils",
3
- "version": "1.6.2",
3
+ "version": "1.6.4",
4
4
  "description": "Miscellaneous tools and utilities to manipulate HTML pages",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"