@xiee/utils
Advanced tools
Comparing version 1.2.14 to 1.3.0
@@ -1,6 +0,6 @@ | ||
(function(d) { | ||
(d => { | ||
const a1 = ['Enter', 'Up', 'Down', 'Left', 'Right']; | ||
const a2 = ['↵', '↑', '↓', '←', '→']; | ||
function drawArrows(x) { | ||
a1.map((v, i) => x = x.replace(new RegExp('>' + v + '<', 'g'), ' title="' + v + (i ? ' Arrow' : '') + '">' + a2[i] + '<')); | ||
a1.map((v, i) => x = x.replace(new RegExp(`>${v}<`, 'g'), ` title="${v + (i ? ' Arrow' : '')}">${a2[i]}<`)); | ||
return x; | ||
@@ -13,5 +13,5 @@ } | ||
k3 = '[a-zA-Z0-9]|Click', | ||
r1 = new RegExp('^(' + k1 + '|' + k2 + ')$'), | ||
r2 = new RegExp('^(' + k2 + ') [/+] '), | ||
r3 = new RegExp('^(' + [k1, k2, k3].join('|') + ')( [/+] )(.*)'); | ||
r1 = new RegExp(`^(${k1}|${k2})$`), | ||
r2 = new RegExp(`^(${k2}) [/+] `), | ||
r3 = new RegExp(`^(${k1}|${k2}|${k3})( [/+] )(.*)`); | ||
d.querySelectorAll(':not(pre) > code').forEach(el => { | ||
@@ -21,3 +21,3 @@ if (el.childElementCount > 0) return; | ||
if (r1.test(t)) { | ||
el.outerHTML = drawArrows('<kbd>' + t + '</kbd>'); | ||
el.outerHTML = drawArrows(`<kbd>${t}</kbd>`); | ||
return; | ||
@@ -24,0 +24,0 @@ } |
@@ -1,1 +0,1 @@ | ||
!function(e){const r=["Enter","Up","Down","Left","Right"],t=["↵","↑","↓","←","→"];function n(e){return r.map(((r,n)=>e=e.replace(new RegExp(">"+r+"<","g"),' title="'+r+(n?" Arrow":"")+'">'+t[n]+"<"))),e}const o="Esc|Tab|PageUp|PageDown|Space|Delete|Home|End|PrtScr?|PrintScreen|"+Array(12).fill().map(((e,r)=>"F"+(r+1))).concat(r).join("|"),c="Ctrl|Control|Shift|Alt|Cmd|Command|fn",a=new RegExp("^("+o+"|"+c+")$"),l=new RegExp("^("+c+") [/+] "),i=new RegExp("^("+[o,c,"[a-zA-Z0-9]|Click"].join("|")+")( [/+] )(.*)");e.querySelectorAll(":not(pre) > code").forEach((e=>{if(e.childElementCount>0)return;let r=e.innerText;if(a.test(r))return void(e.outerHTML=n("<kbd>"+r+"</kbd>"));if(!l.test(r))return;let t="";for(r+=" + ";i.test(r);)t+=r.replace(i,"<kbd>$1</kbd>$2"),r=r.replace(i,"$3");""===r&&(e.outerHTML=n(t.replace(/ \+ $/,"")))}))}(document); | ||
(e=>{const r=["Enter","Up","Down","Left","Right"],t=["↵","↑","↓","←","→"];function n(e){return r.map(((r,n)=>e=e.replace(new RegExp(`>${r}<`,"g"),` title="${r+(n?" Arrow":"")}">${t[n]}<`))),e}const o="Esc|Tab|PageUp|PageDown|Space|Delete|Home|End|PrtScr?|PrintScreen|"+Array(12).fill().map(((e,r)=>"F"+(r+1))).concat(r).join("|"),a="Ctrl|Control|Shift|Alt|Cmd|Command|fn",c=new RegExp(`^(${o}|${a})$`),l=new RegExp(`^(${a}) [/+] `),i=new RegExp(`^(${o}|${a}|[a-zA-Z0-9]|Click)( [/+] )(.*)`);e.querySelectorAll(":not(pre) > code").forEach((e=>{if(e.childElementCount>0)return;let r=e.innerText;if(c.test(r))return void(e.outerHTML=n(`<kbd>${r}</kbd>`));if(!l.test(r))return;let t="";for(r+=" + ";i.test(r);)t+=r.replace(i,"<kbd>$1</kbd>$2"),r=r.replace(i,"$3");""===r&&(e.outerHTML=n(t.replace(/ \+ $/,"")))}))})(document); |
// 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'; | ||
if (el?.tagName === 'P' && /^(—|---)/.test(el.textContent)) el.style.textAlign = 'right'; | ||
}); |
@@ -1,1 +0,1 @@ | ||
[...document.getElementsByTagName("blockquote")].forEach((t=>{const e=t.lastElementChild;"P"===e?.tagName&&/^—/.test(e.textContent)&&(e.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.14", | ||
"version": "1.3.0", | ||
"description": "Miscellaneous tools and utilities to manipulate HTML pages", | ||
@@ -5,0 +5,0 @@ "scripts": { |
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
48708
61
763