@xiee/utils 1.2.12 → 1.2.14
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 +2 -2
- package/css/heading-anchor.css +2 -0
- package/css/heading-anchor.min.css +1 -0
- package/js/alt-title.js +3 -7
- package/js/alt-title.min.js +1 -1
- package/js/center-img.js +2 -3
- package/js/center-img.min.js +1 -1
- package/js/comment-utils.js +4 -4
- package/js/comment-utils.min.js +1 -1
- package/js/heading-anchor.js +3 -0
- package/js/heading-anchor.min.js +1 -0
- package/js/right-quote.js +5 -12
- package/js/right-quote.min.js +1 -1
- package/package.json +1 -1
- package/js/header-link.js +0 -5
- package/js/header-link.min.js +0 -1
package/README.md
CHANGED
|
@@ -63,9 +63,9 @@ Convert HTML comments of the form `<!--# comments -->` to
|
|
|
63
63
|
document body will gain classes `has-notes` and `hide-notes`. You can use CSS to
|
|
64
64
|
style the notes or hide/show them as you wish.
|
|
65
65
|
|
|
66
|
-
##
|
|
66
|
+
## heading-anchor.js
|
|
67
67
|
|
|
68
|
-
Add anchor links to all section
|
|
68
|
+
Add anchor links to all section headings (e.g., `<h2>`) that have nonempty `id`
|
|
69
69
|
attributes.
|
|
70
70
|
|
|
71
71
|
## key-buttons.js
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.anchor{display:none}:hover>.anchor{display:inline}
|
package/js/alt-title.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
(
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
img = imgs[i];
|
|
5
|
-
if (!img.title) img.title = img.alt;
|
|
6
|
-
}
|
|
7
|
-
})();
|
|
1
|
+
[...document.getElementsByTagName('img')].forEach(el => {
|
|
2
|
+
if (!el.title) el.title = el.alt;
|
|
3
|
+
});
|
package/js/alt-title.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
[...document.getElementsByTagName("img")].forEach((t=>{t.title||(t.title=t.alt)}));
|
package/js/center-img.js
CHANGED
|
@@ -24,14 +24,13 @@
|
|
|
24
24
|
if (parent.nodeName === 'P') {
|
|
25
25
|
parent.style.textAlign = 'center';
|
|
26
26
|
if (!parentA && tagName === 'img') {
|
|
27
|
-
parent.innerHTML =
|
|
28
|
-
tag.outerHTML + '</a>';
|
|
27
|
+
parent.innerHTML = `<a href="${tag.src}" style="border: none;">${tag.outerHTML}</a>`;
|
|
29
28
|
}
|
|
30
29
|
}
|
|
31
30
|
}
|
|
32
31
|
});
|
|
33
32
|
}
|
|
34
|
-
['img', 'embed', 'object'].forEach(
|
|
33
|
+
['img', 'embed', 'object'].forEach(center_el);
|
|
35
34
|
// also center paragraphs that contain `* * *`
|
|
36
35
|
d.querySelectorAll('p').forEach(p => {
|
|
37
36
|
if (p.innerText === '* * *') p.style.textAlign = 'center';
|
package/js/center-img.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e){function t(e){if(1!==e.childElementCount)return!1;const t=e.childNodes;if(1===t.length)return!0;for(let e in t){let n=t[e];if("#text"===n.nodeName&&!/^\s$/.test(n.textContent))return!1}return!0}["img","embed","object"].forEach((n
|
|
1
|
+
!function(e){function t(e){if(1!==e.childElementCount)return!1;const t=e.childNodes;if(1===t.length)return!0;for(let e in t){let n=t[e];if("#text"===n.nodeName&&!/^\s$/.test(n.textContent))return!1}return!0}["img","embed","object"].forEach((function(n){e.querySelectorAll(n).forEach((e=>{let r=e.parentElement;if(t(r)){const o="A"===r.nodeName;if(o){if(r=r.parentElement,!t(r))return;r.firstElementChild.style.border="none"}"P"===r.nodeName&&(r.style.textAlign="center",o||"img"!==n||(r.innerHTML=`<a href="${e.src}" style="border: none;">${e.outerHTML}</a>`))}}))})),e.querySelectorAll("p").forEach((e=>{"* * *"===e.innerText&&(e.style.textAlign="center")}))}(document);
|
package/js/comment-utils.js
CHANGED
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
// create a new script and change attribute 'data-src' to 'src' (to actually load the script)
|
|
17
17
|
const s = a.querySelector('script[data-src]');
|
|
18
18
|
if (!s) return;
|
|
19
|
-
const r = s.dataset.src, s2 = d.createElement('script')
|
|
20
|
-
|
|
21
|
-
s2.setAttribute(b
|
|
22
|
-
}
|
|
19
|
+
const r = s.dataset.src, s2 = d.createElement('script');
|
|
20
|
+
[...s.attributes].forEach(b => {
|
|
21
|
+
s2.setAttribute(b.name, b.value);
|
|
22
|
+
});
|
|
23
23
|
s2.src = r;
|
|
24
24
|
s.remove();
|
|
25
25
|
a.appendChild(s2);
|
package/js/comment-utils.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t){const e=t.querySelector("section.comments");if(!e)return;if(function(){let t=!0;try{t=window.self!==window.top}catch(t){}return t}())return void e.remove();location.hash.match(/^#comment-[0-9]+$/)&&e.scrollIntoView();const r=e.querySelector("script[data-src]");if(!r)return;const
|
|
1
|
+
!function(t){const e=t.querySelector("section.comments");if(!e)return;if(function(){let t=!0;try{t=window.self!==window.top}catch(t){}return t}())return void e.remove();location.hash.match(/^#comment-[0-9]+$/)&&e.scrollIntoView();const r=e.querySelector("script[data-src]");if(!r)return;const c=r.dataset.src,n=t.createElement("script");[...r.attributes].forEach((t=>{n.setAttribute(t.name,t.value)})),n.src=c,r.remove(),e.appendChild(n)}(document);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
document.querySelectorAll("h1,h2,h3,h4,h5,h6").forEach((h=>{h.id&&(h.innerHTML+=` <span class="anchor"><a href="#${h.id}">#</a></span>`)}));
|
package/js/right-quote.js
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (n === 0) continue;
|
|
7
|
-
var el = quote.children[n - 1];
|
|
8
|
-
if (!el || el.nodeName !== 'P') continue;
|
|
9
|
-
// right-align a quote footer if it starts with ---
|
|
10
|
-
if (/^—/.test(el.textContent)) el.style.textAlign = 'right';
|
|
11
|
-
}
|
|
12
|
-
})();
|
|
1
|
+
// right-align a quote footer if it starts with ---
|
|
2
|
+
[...document.getElementsByTagName('blockquote')].forEach(quote => {
|
|
3
|
+
const el = quote.lastElementChild;
|
|
4
|
+
if (el?.tagName === 'P' && /^—/.test(el.textContent)) el.style.textAlign = 'right';
|
|
5
|
+
});
|
package/js/right-quote.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
[...document.getElementsByTagName("blockquote")].forEach((t=>{const e=t.lastElementChild;"P"===e?.tagName&&/^—/.test(e.textContent)&&(e.style.textAlign="right")}));
|
package/package.json
CHANGED
package/js/header-link.js
DELETED
package/js/header-link.min.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
document.querySelectorAll("h1,h2,h3").forEach((a=>{a.id&&(a.innerHTML+=` <span class="anchor"><a href="#${a.id}">#</a></span>`)}));
|