@xiee/utils 1.3.7 → 1.3.9

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/README.md CHANGED
@@ -5,7 +5,7 @@ via [jsdelivr.com](https://www.jsdelivr.com), e.g.,
5
5
 
6
6
  ``` html
7
7
  <script src="https://cdn.jsdelivr.net/npm/@xiee/utils/js/faq.min.js" defer></script>
8
- <link href="https://cdn.jsdelivr.net/npm/@xiee/utils/css/faq.min.css" rel="stylesheet"></link>
8
+ <link href="https://cdn.jsdelivr.net/npm/@xiee/utils/css/faq.min.css" rel="stylesheet">
9
9
  ```
10
10
 
11
11
  See the full documentation at <https://yihui.org/en/2018/11/md-js-tricks/>.
package/css/article.css CHANGED
@@ -82,7 +82,7 @@ body, blockquote, .side, .menu { background: #fafafa; }
82
82
 
83
83
  @media (min-width: 1280px) {
84
84
  .note-ref { cursor: pointer; }
85
- .note-ref:hover ~ .side {
85
+ .note-ref:hover + .side {
86
86
  display: inline-block;
87
87
  background-color: #f8f8f8;
88
88
  position: absolute;
@@ -108,7 +108,7 @@ body, blockquote, .side, .menu { background: #fafafa; }
108
108
  margin: 1em auto;
109
109
  background: none;
110
110
  }
111
- .note-ref ~ .side { margin-left: 100vw; }
111
+ .note-ref + .side { margin-left: 100vw; }
112
112
  .side > :last-child { margin-bottom: 0; }
113
113
  .embed-left, .embed-right {
114
114
  float: inherit;
@@ -1 +1 @@
1
- .menu,.side,blockquote,body{background:#fafafa}.appendix,.article,.body{position:relative}.article-list,.body,.body~.appendix,.embed-left,.embed-right,.frontmatter,.fullwidth,.single .appendix,.single main{margin-top:2em;padding:1em;box-shadow:0 0 8px #ccc;background:#fff}.article-meta{background:#f8f8f8}.appendix,.article-meta .terms,.body .side,.caption,.footnotes,figcaption,main .side>*{font-size:.9em}.body~.appendix,.frontmatter,.single .appendix{background:0 0}.appendix h2{border-bottom:1px dashed #666}#TOC{top:0}#TOC ul{list-style-position:inside}#TOC>ul{padding:0;margin:0}#TOC li>ul{padding-left:1em}#TOC .numbered{list-style:none}.bg-number{padding:1px 5px;border-radius:5px;background:#778899;color:#fff}.side{width:200px;margin:0 auto}.side-left{float:left;clear:left;margin-left:calc(-200px - 2em);position:sticky}.side-right{float:right;clear:right;margin-right:calc(-200px - 2em)}.quote-left,.quote-right{width:45%}.embed-left,.embed-right{margin-top:auto;padding:0}.embed-left,.quote-left{float:left;margin-right:1em}.embed-right,.quote-right{float:right;margin-left:1em}.embed-left{margin-left:calc(-200px - 2em)}.embed-right{margin-right:calc(-200px - 2em)}.embed-left>:first-child,.embed-right>:first-child,.side>:first-child{margin-top:0}.embed-left>:last-child,.embed-right>:last-child{margin-bottom:0}.quote-left>:first-child,.quote-right>:first-child{padding-top:.1px}.quote-left>:last-child,.quote-right>:last-child{padding-bottom:.1px}.fullwidth,.fullwidth *{margin:auto 0}.fullwidth *{max-width:calc(100vw - 4em)}.fullscroll *{max-width:initial}.fullwidth{max-width:calc(100vw - 2em);margin:1em 0 1em 50%;transform:translateX(-50%);float:left;min-width:100%;background:#fff}.fullscroll,.fullscroll .figure,.fullscroll figure{overflow-x:auto}.fullwidth .caption,.fullwidth figcaption{margin-left:calc(50% - 400px);width:800px;padding:1em 1em 0}@media (min-width:1280px){.note-ref{cursor:pointer}.note-ref:hover~.side{display:inline-block;background-color:#f8f8f8;position:absolute;margin-left:1em;padding:.5em;box-sizing:content-box}}@media (max-width:1280px){#TOC{border:1px solid #eee;border-radius:5px;padding:1em;position:initial}.side{width:100%}.body .side,main .side{padding:0 2em;color:#2f4f4f}.side-left,.side-right{clear:both;margin:1em auto;background:0 0}.note-ref~.side{margin-left:100vw}.side>:last-child{margin-bottom:0}.embed-left,.embed-right{float:inherit;margin:auto;padding:1em}}@media (max-width:800px){body{padding:initial}.body,main{padding:0 .5em 0}.quote-left,.quote-right{width:inherit;float:inherit;margin:auto}.fullwidth:not(.fullscroll) *{max-width:100%}.fullwidth{margin:initial;transform:initial;float:none;min-width:initial;background:0 0;border:none}.fullwidth .caption,.fullwidth figcaption{margin:initial;padding:initial}}
1
+ .menu,.side,blockquote,body{background:#fafafa}.appendix,.article,.body{position:relative}.article-list,.body,.body~.appendix,.embed-left,.embed-right,.frontmatter,.fullwidth,.single .appendix,.single main{margin-top:2em;padding:1em;box-shadow:0 0 8px #ccc;background:#fff}.article-meta{background:#f8f8f8}.appendix,.article-meta .terms,.body .side,.caption,.footnotes,figcaption,main .side>*{font-size:.9em}.body~.appendix,.frontmatter,.single .appendix{background:0 0}.appendix h2{border-bottom:1px dashed #666}#TOC{top:0}#TOC ul{list-style-position:inside}#TOC>ul{padding:0;margin:0}#TOC li>ul{padding-left:1em}#TOC .numbered{list-style:none}.bg-number{padding:1px 5px;border-radius:5px;background:#778899;color:#fff}.side{width:200px;margin:0 auto}.side-left{float:left;clear:left;margin-left:calc(-200px - 2em);position:sticky}.side-right{float:right;clear:right;margin-right:calc(-200px - 2em)}.quote-left,.quote-right{width:45%}.embed-left,.embed-right{margin-top:auto;padding:0}.embed-left,.quote-left{float:left;margin-right:1em}.embed-right,.quote-right{float:right;margin-left:1em}.embed-left{margin-left:calc(-200px - 2em)}.embed-right{margin-right:calc(-200px - 2em)}.embed-left>:first-child,.embed-right>:first-child,.side>:first-child{margin-top:0}.embed-left>:last-child,.embed-right>:last-child{margin-bottom:0}.quote-left>:first-child,.quote-right>:first-child{padding-top:.1px}.quote-left>:last-child,.quote-right>:last-child{padding-bottom:.1px}.fullwidth,.fullwidth *{margin:auto 0}.fullwidth *{max-width:calc(100vw - 4em)}.fullscroll *{max-width:initial}.fullwidth{max-width:calc(100vw - 2em);margin:1em 0 1em 50%;transform:translateX(-50%);float:left;min-width:100%;background:#fff}.fullscroll,.fullscroll .figure,.fullscroll figure{overflow-x:auto}.fullwidth .caption,.fullwidth figcaption{margin-left:calc(50% - 400px);width:800px;padding:1em 1em 0}@media (min-width:1280px){.note-ref{cursor:pointer}.note-ref:hover+.side{display:inline-block;background-color:#f8f8f8;position:absolute;margin-left:1em;padding:.5em;box-sizing:content-box}}@media (max-width:1280px){#TOC{border:1px solid #eee;border-radius:5px;padding:1em;position:initial}.side{width:100%}.body .side,main .side{padding:0 2em;color:#2f4f4f}.side-left,.side-right{clear:both;margin:1em auto;background:0 0}.note-ref+.side{margin-left:100vw}.side>:last-child{margin-bottom:0}.embed-left,.embed-right{float:inherit;margin:auto;padding:1em}}@media (max-width:800px){body{padding:initial}.body,main{padding:0 .5em 0}.quote-left,.quote-right{width:inherit;float:inherit;margin:auto}.fullwidth:not(.fullscroll) *{max-width:100%}.fullwidth{margin:initial;transform:initial;float:none;min-width:initial;background:0 0;border:none}.fullwidth .caption,.fullwidth figcaption{margin:initial;padding:initial}}
package/js/toc.js CHANGED
@@ -8,10 +8,13 @@
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
- var toc = d.getElementById('TOC');
12
- toc?.remove(); // delete and rebuild TOC if it has been generated (e.g., by Pandoc)
13
- toc = d.createElement('div');
14
- toc.id = 'TOC';
11
+ let toc = d.getElementById('TOC');
12
+ if (toc) {
13
+ toc.innerHTML = ''; // empty and rebuild TOC if it has been generated (e.g., by Pandoc)
14
+ } else {
15
+ toc = d.createElement('div');
16
+ toc.id = 'TOC';
17
+ }
15
18
 
16
19
  let li, ul;
17
20
  let p = toc; // the current parent into which we insert child TOC items
@@ -44,9 +47,11 @@
44
47
  p.appendChild(a);
45
48
  t0 = t1;
46
49
  });
47
- // if there is <header> in the article body, insert TOC after it
48
- const header = b.querySelector('header');
49
- header ? header.after(toc) : b.insertBefore(toc, b.firstChild);
50
+ if (!toc.parentNode) {
51
+ // if there is <header> in the article body, insert TOC after it
52
+ const header = b.querySelector('header');
53
+ header ? header.after(toc) : b.insertBefore(toc, b.firstChild);
54
+ }
50
55
 
51
56
  // check if headings are numbered
52
57
  toc.querySelector('span.section-number') && toc.firstElementChild.classList.add('numbered');
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;var n=e.getElementById("TOC");let l,i;n?.remove(),(n=e.createElement("div")).id="TOC";let a,d=n,o=0;r.forEach((t=>{if(a=parseInt(t.tagName.replace(/^h/i,"")),l=e.createElement("li"),a>o)i=e.createElement("ul"),i.appendChild(l),d.appendChild(i);else if(a<o)for(let e=0;e<o-a;e++)d=d.parentNode.parentNode;a<=o&&d.parentNode.appendChild(l),d=l;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}));const c=t.querySelector("header");c?c.after(n):t.insertBefore(n,t.firstChild),n.querySelector("span.section-number")&&n.firstElementChild.classList.add("numbered")})(document);
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xiee/utils",
3
- "version": "1.3.7",
3
+ "version": "1.3.9",
4
4
  "description": "Miscellaneous tools and utilities to manipulate HTML pages",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"