@xiee/utils
Advanced tools
Comparing version 1.2.12 to 1.2.13
@@ -1,7 +0,3 @@ | ||
(function() { | ||
var img, imgs = document.getElementsByTagName('img'); | ||
for (var i = 0; i < imgs.length; i++) { | ||
img = imgs[i]; | ||
if (!img.title) img.title = img.alt; | ||
} | ||
})(); | ||
[...document.getElementsByTagName('img')].forEach(el => { | ||
if (!el.title) el.title = el.alt; | ||
}); |
@@ -1,1 +0,1 @@ | ||
!function(){for(var t,e=document.getElementsByTagName("img"),l=0;l<e.length;l++)(t=e[l]).title||(t.title=t.alt)}(); | ||
[...document.getElementsByTagName("img")].forEach((t=>{t.title||(t.title=t.alt)})); |
@@ -27,4 +27,3 @@ (function(d) { | ||
if (!parentA && tagName === 'img') { | ||
parent.innerHTML = '<a href="' + tag.src + '" style="border: none;">' + | ||
tag.outerHTML + '</a>'; | ||
parent.innerHTML = `<a href="${tag.src}" style="border: none;">${tag.outerHTML}</a>`; | ||
} | ||
@@ -35,3 +34,3 @@ } | ||
} | ||
['img', 'embed', 'object'].forEach(tag => center_el(tag)); | ||
['img', 'embed', 'object'].forEach(center_el); | ||
// also center paragraphs that contain `* * *` | ||
@@ -38,0 +37,0 @@ d.querySelectorAll('p').forEach(p => { |
@@ -1,1 +0,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=>{return r=n,void e.querySelectorAll(r).forEach((e=>{let n=e.parentElement;if(t(n)){const o="A"===n.nodeName;if(o){if(n=n.parentElement,!t(n))return;n.firstElementChild.style.border="none"}"P"===n.nodeName&&(n.style.textAlign="center",o||"img"!==r||(n.innerHTML='<a href="'+e.src+'" style="border: none;">'+e.outerHTML+"</a>"))}}));var r})),e.querySelectorAll("p").forEach((e=>{"* * *"===e.innerText&&(e.style.textAlign="center")}))}(document); | ||
!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); |
@@ -19,6 +19,6 @@ (function(d) { | ||
if (!s) return; | ||
const r = s.dataset.src, s2 = d.createElement('script'), b = s.attributes; | ||
for (let i = 0; i < b.length; i++) { | ||
s2.setAttribute(b[i].name, b[i].value); | ||
} | ||
const r = s.dataset.src, s2 = d.createElement('script'); | ||
[...s.attributes].forEach(b => { | ||
s2.setAttribute(b.name, b.value); | ||
}); | ||
s2.src = r; | ||
@@ -25,0 +25,0 @@ s.remove(); |
@@ -1,1 +0,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 n=r.dataset.src,c=t.createElement("script"),o=r.attributes;for(let t=0;t<o.length;t++)c.setAttribute(o[t].name,o[t].value);c.src=n,r.remove(),e.appendChild(c)}(document); | ||
!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); |
@@ -1,12 +0,5 @@ | ||
(function() { | ||
var quotes = document.getElementsByTagName('blockquote'), i, quote; | ||
for (i = 0; i < quotes.length; i++) { | ||
quote = quotes[i]; | ||
var n = quote.children.length; | ||
if (n === 0) continue; | ||
var el = quote.children[n - 1]; | ||
if (!el || el.nodeName !== 'P') continue; | ||
// right-align a quote footer if it starts with --- | ||
if (/^—/.test(el.textContent)) el.style.textAlign = 'right'; | ||
} | ||
})(); | ||
// right-align a quote footer if it starts with --- | ||
[...document.getElementsByTagName('blockquote')].forEach(quote => { | ||
const el = quote.lastElementChild; | ||
if (el?.tagName === 'P' && /^—/.test(el.textContent)) el.style.textAlign = 'right'; | ||
}); |
@@ -1,1 +0,1 @@ | ||
!function(){var e,t,n=document.getElementsByTagName("blockquote");for(e=0;e<n.length;e++){var l=(t=n[e]).children.length;if(0!==l){var o=t.children[l-1];o&&"P"===o.nodeName&&/^—/.test(o.textContent)&&(o.style.textAlign="right")}}}(); | ||
[...document.getElementsByTagName("blockquote")].forEach((t=>{const e=t.lastElementChild;"P"===e?.tagName&&/^—/.test(e.textContent)&&(e.style.textAlign="right")})); |
{ | ||
"name": "@xiee/utils", | ||
"version": "1.2.12", | ||
"version": "1.2.13", | ||
"description": "Miscellaneous tools and utilities to manipulate HTML pages", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -66,5 +66,5 @@ This repo contains miscellaneous tools and utilities written in JavaScript. They | ||
## header-link.js | ||
## heading-anchor.js | ||
Add anchor links to all section headers (e.g., `<h2>`) that have nonempty `id` | ||
Add anchor links to all section headings (e.g., `<h2>`) that have nonempty `id` | ||
attributes. | ||
@@ -71,0 +71,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
51
35151
495