Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@xiee/utils

Package Overview
Dependencies
Maintainers
0
Versions
170
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@xiee/utils - npm Package Compare versions

Comparing version 1.12.28 to 1.12.29

52

js/sidenotes.js
// move footnotes (ids start with fn) and citations (ids start with ref-) to sidenotes
(d => {
d.querySelectorAll('.footnotes > ol > li[id^="fn"], #refs > div[id^="ref-"]').forEach(el => {
d.querySelectorAll('.footnotes > ol > li[id^="fn"], #refs > *[id^="ref-"]').forEach(el => {
// find <a> that points to note id in body
const h = `a[href="#${el.id}"]`,
a = d.querySelector(`${h} > sup, sup > ${h}, .citation > ${h}`);
if (!a) return;
const a2 = a.parentNode;
(a.tagName === 'A' ? a : a2).removeAttribute('href');
const s = d.createElement('div'); // insert a side div next to a2 in body
s.className = 'side side-right';
if (/^fn/.test(el.id)) {
s.innerHTML = el.innerHTML;
// add footnote number
s.firstElementChild.insertAdjacentHTML('afterbegin', `<span class="bg-number">${a.innerText}</span> `);
s.querySelector('a[href^="#fnref"]')?.remove(); // remove backreference
s.className += ' footnotes';
} else {
s.innerHTML = el.outerHTML;
}
while (s.lastChild?.nodeName === '#text' && /^\s*$/.test(s.lastChild.textContent)) {
s.lastChild.remove();
}
// remove fullwidth classes if present (because they cannot be used in the margin)
s.querySelectorAll('.fullwidth').forEach(el => el.classList.remove('fullwidth'));
// insert note after the <sup> or <span> that contains a
a2.after(s);
a2.classList.add('note-ref');
el.remove();
const h = `a[href="#${el.id}"]`;
d.querySelectorAll(`${h} > sup, sup > ${h}, .citation > ${h}`).forEach(a => {
const a2 = a.parentNode;
(a.tagName === 'A' ? a : a2).removeAttribute('href');
const s = d.createElement('div'); // insert a side div next to a2 in body
s.className = 'side side-right';
if (/^fn/.test(el.id)) {
s.innerHTML = el.innerHTML;
// add footnote number
s.firstElementChild.insertAdjacentHTML('afterbegin', `<span class="bg-number">${a.innerText}</span> `);
s.querySelector('a[href^="#fnref"]')?.remove(); // remove backreference
s.className += ' footnotes';
} else {
s.innerHTML = el.outerHTML;
}
while (s.lastChild?.nodeName === '#text' && /^\s*$/.test(s.lastChild.textContent)) {
s.lastChild.remove();
}
// remove fullwidth classes if present (because they cannot be used in the margin)
s.querySelectorAll('.fullwidth').forEach(el => el.classList.remove('fullwidth'));
// insert note after the <sup> or <span> that contains a
a2.after(s);
a2.classList.add('note-ref');
el.remove();
});
});

@@ -31,0 +31,0 @@ // remove the footnote/citation section if it's empty now

@@ -1,1 +0,1 @@

(e=>{e.querySelectorAll('.footnotes > ol > li[id^="fn"], #refs > div[id^="ref-"]').forEach((t=>{const s=`a[href="#${t.id}"]`,r=e.querySelector(`${s} > sup, sup > ${s}, .citation > ${s}`);if(!r)return;const o=r.parentNode;("A"===r.tagName?r:o).removeAttribute("href");const l=e.createElement("div");for(l.className="side side-right",/^fn/.test(t.id)?(l.innerHTML=t.innerHTML,l.firstElementChild.insertAdjacentHTML("afterbegin",`<span class="bg-number">${r.innerText}</span> `),l.querySelector('a[href^="#fnref"]')?.remove(),l.className+=" footnotes"):l.innerHTML=t.outerHTML;"#text"===l.lastChild?.nodeName&&/^\s*$/.test(l.lastChild.textContent);)l.lastChild.remove();l.querySelectorAll(".fullwidth").forEach((e=>e.classList.remove("fullwidth"))),o.after(l),o.classList.add("note-ref"),t.remove()})),e.querySelectorAll(".footnotes, #refs").forEach((e=>{/^\s*$/.test(e.innerText)&&e.remove()})),e.getElementById("TOC")?.classList.add("side","side-left");const t=e.querySelectorAll(".side.side-right, .side.side-left"),s=[];e.querySelectorAll(".fullwidth").forEach((e=>{s.push([e,e.getBoundingClientRect()])})),t.length&&e.body.classList.add("has-sidenotes"),t.forEach((e=>{const t=e.getBoundingClientRect();for(let e of s){const s=e[1];t.right<s.left||t.left>s.right||t.bottom<s.top||t.top>s.bottom||e[0].classList.remove("fullwidth")}}))})(document);
(e=>{e.querySelectorAll('.footnotes > ol > li[id^="fn"], #refs > *[id^="ref-"]').forEach((t=>{const s=`a[href="#${t.id}"]`;e.querySelectorAll(`${s} > sup, sup > ${s}, .citation > ${s}`).forEach((s=>{const o=s.parentNode;("A"===s.tagName?s:o).removeAttribute("href");const l=e.createElement("div");for(l.className="side side-right",/^fn/.test(t.id)?(l.innerHTML=t.innerHTML,l.firstElementChild.insertAdjacentHTML("afterbegin",`<span class="bg-number">${s.innerText}</span> `),l.querySelector('a[href^="#fnref"]')?.remove(),l.className+=" footnotes"):l.innerHTML=t.outerHTML;"#text"===l.lastChild?.nodeName&&/^\s*$/.test(l.lastChild.textContent);)l.lastChild.remove();l.querySelectorAll(".fullwidth").forEach((e=>e.classList.remove("fullwidth"))),o.after(l),o.classList.add("note-ref"),t.remove()}))})),e.querySelectorAll(".footnotes, #refs").forEach((e=>{/^\s*$/.test(e.innerText)&&e.remove()})),e.getElementById("TOC")?.classList.add("side","side-left");const t=e.querySelectorAll(".side.side-right, .side.side-left"),s=[];e.querySelectorAll(".fullwidth").forEach((e=>{s.push([e,e.getBoundingClientRect()])})),t.length&&e.body.classList.add("has-sidenotes"),t.forEach((e=>{const t=e.getBoundingClientRect();for(let e of s){const s=e[1];t.right<s.left||t.left>s.right||t.bottom<s.top||t.top>s.bottom||e[0].classList.remove("fullwidth")}}))})(document);
{
"name": "@xiee/utils",
"version": "1.12.28",
"version": "1.12.29",
"description": "Miscellaneous tools and utilities to manipulate HTML pages",

@@ -5,0 +5,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc