@xiee/utils 1.14.20 → 1.14.21

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/appendix.js CHANGED
@@ -11,14 +11,22 @@
11
11
  }
12
12
  // if h is in a wrapper whose prev/next sibling has the same class, simply add class to wrappers
13
13
  const p1 = h.parentNode, p0 = p1.previousElementSibling;
14
- let wrapper = sameClass(p1, p0), p2 = p1;
14
+ let has_wrapper = sameClass(p1, p0), h0 = h, p2 = p1;
15
+ // if has_wrapper == false, check if there's any sibling heading before h
16
+ if (!has_wrapper) while (true) {
17
+ h0 = h0.previousElementSibling;
18
+ if (!h0) break;
19
+ // if a heading is found, assume the appendix needs a new wrapper
20
+ has_wrapper = !/^H[1-6]/.test(h0.tagName);
21
+ if (!has_wrapper) break; // heading found, appendix doesn't have wrapper
22
+ }
15
23
  while (p1) {
16
24
  p2 = p2.nextElementSibling;
17
25
  if (!sameClass(p1, p2)) break;
18
26
  p2.classList.add('appendix');
19
- wrapper = true;
27
+ has_wrapper = true;
20
28
  }
21
- if (wrapper) {
29
+ if (has_wrapper) {
22
30
  p1.classList.add('appendix');
23
31
  return;
24
32
  }
@@ -1,2 +1,2 @@
1
- (e=>{const n=e.querySelector([1,2,3,4,5,6].map(e=>`h${e}.appendix`).join(","));if(!n)return;function a(e,n){return e&&n&&e.tagName===n.tagName&&e.className===n.className}n.classList.remove("appendix");const t=n.parentNode;let i=a(t,t.previousElementSibling),p=t;for(;t&&(p=p.nextElementSibling,a(t,p));)p.classList.add("appendix"),i=!0;if(i)return void t.classList.add("appendix");const d=e.createElement("div");for(d.className="appendix",d.append(n.cloneNode(!0));n.nextSibling;)d.append(n.nextSibling);"BODY"===n.parentNode.tagName?e.body.append(d):n.parentNode.after(d),n.remove()})(document);
1
+ (e=>{const n=e.querySelector([1,2,3,4,5,6].map(e=>`h${e}.appendix`).join(","));if(!n)return;function a(e,n){return e&&n&&e.tagName===n.tagName&&e.className===n.className}n.classList.remove("appendix");const t=n.parentNode;let i=a(t,t.previousElementSibling),p=n,o=t;if(!i)for(;p=p.previousElementSibling,p&&(i=!/^H[1-6]/.test(p.tagName),i););for(;t&&(o=o.nextElementSibling,a(t,o));)o.classList.add("appendix"),i=!0;if(i)return void t.classList.add("appendix");const s=e.createElement("div");for(s.className="appendix",s.append(n.cloneNode(!0));n.nextSibling;)s.append(n.nextSibling);"BODY"===n.parentNode.tagName?e.body.append(s):n.parentNode.after(s),n.remove()})(document);
2
2
  //# sourceMappingURL=appendix.min.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["d","h","querySelector","map","i","join","sameClass","e1","e2","tagName","className","classList","remove","p1","parentNode","wrapper","previousElementSibling","p2","nextElementSibling","add","a","createElement","append","cloneNode","nextSibling","body","after","document"],"sources":["appendix.js"],"mappings":"AAGA,CAACA,IACC,MAAMC,EAAID,EAAEE,cAAc,CAAC,EAAG,EAAG,EAAG,EAAG,EAAG,GAAGC,IAAIC,GAAK,IAAIA,cAAcC,KAAK,MAC7E,IAAKJ,EAAG,OAGR,SAASK,EAAUC,EAAIC,GACrB,OAAOD,GAAMC,GAAMD,EAAGE,UAAYD,EAAGC,SAAWF,EAAGG,YAAcF,EAAGE,SACtE,CAJAT,EAAEU,UAAUC,OAAO,YAMnB,MAAMC,EAAKZ,EAAEa,WACb,IAAIC,EAAUT,EAAUO,EADMA,EAAGG,wBACAC,EAAKJ,EACtC,KAAOA,IACLI,EAAKA,EAAGC,mBACHZ,EAAUO,EAAII,KACnBA,EAAGN,UAAUQ,IAAI,YACjBJ,GAAU,EAEZ,GAAIA,EAEF,YADAF,EAAGF,UAAUQ,IAAI,YAInB,MAAMC,EAAIpB,EAAEqB,cAAc,OAG1B,IAFAD,EAAEV,UAAY,WACdU,EAAEE,OAAOrB,EAAEsB,WAAU,IACftB,EAAEuB,aACNJ,EAAEE,OAAOrB,EAAEuB,aAEY,SAAzBvB,EAAEa,WAAWL,QAAqBT,EAAEyB,KAAKH,OAAOF,GAAKnB,EAAEa,WAAWY,MAAMN,GACxEnB,EAAEW,QACH,EA9BD,CA8BGe","ignoreList":[]}
1
+ {"version":3,"names":["d","h","querySelector","map","i","join","sameClass","e1","e2","tagName","className","classList","remove","p1","parentNode","has_wrapper","previousElementSibling","h0","p2","test","nextElementSibling","add","a","createElement","append","cloneNode","nextSibling","body","after","document"],"sources":["appendix.js"],"mappings":"AAGA,CAACA,IACC,MAAMC,EAAID,EAAEE,cAAc,CAAC,EAAG,EAAG,EAAG,EAAG,EAAG,GAAGC,IAAIC,GAAK,IAAIA,cAAcC,KAAK,MAC7E,IAAKJ,EAAG,OAGR,SAASK,EAAUC,EAAIC,GACrB,OAAOD,GAAMC,GAAMD,EAAGE,UAAYD,EAAGC,SAAWF,EAAGG,YAAcF,EAAGE,SACtE,CAJAT,EAAEU,UAAUC,OAAO,YAMnB,MAAMC,EAAKZ,EAAEa,WACb,IAAIC,EAAcT,EAAUO,EADEA,EAAGG,wBACIC,EAAKhB,EAAGiB,EAAKL,EAElD,IAAKE,EAAa,KAChBE,EAAKA,EAAGD,uBACHC,IAELF,GAAe,UAAUI,KAAKF,EAAGR,SAC5BM,KAEP,KAAOF,IACLK,EAAKA,EAAGE,mBACHd,EAAUO,EAAIK,KACnBA,EAAGP,UAAUU,IAAI,YACjBN,GAAc,EAEhB,GAAIA,EAEF,YADAF,EAAGF,UAAUU,IAAI,YAInB,MAAMC,EAAItB,EAAEuB,cAAc,OAG1B,IAFAD,EAAEZ,UAAY,WACdY,EAAEE,OAAOvB,EAAEwB,WAAU,IACfxB,EAAEyB,aACNJ,EAAEE,OAAOvB,EAAEyB,aAEY,SAAzBzB,EAAEa,WAAWL,QAAqBT,EAAE2B,KAAKH,OAAOF,GAAKrB,EAAEa,WAAWc,MAAMN,GACxErB,EAAEW,QACH,EAtCD,CAsCGiB","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xiee/utils",
3
- "version": "1.14.20",
3
+ "version": "1.14.21",
4
4
  "description": "Miscellaneous tools and utilities to manipulate HTML pages",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"