@xiee/utils
Advanced tools
Comparing version 1.2.8 to 1.2.9
(function(d) { | ||
function fix_footnote(tagName) { | ||
let tags = d.getElementsByTagName(tagName), i, tag, tag2, n = 1, href; | ||
for (i = 0; i < tags.length; i++) { | ||
tag = tags[i]; | ||
if (tagName === 'sup') { | ||
if (tag.className !== 'footnote-ref' || tag.id !== 'fnref:-') continue; | ||
tag.id += n; | ||
if (tag.children.length === 1) { | ||
tag2 = tag.children[0]; | ||
href = tag2.getAttribute('href'); | ||
if (tag2.nodeName === 'A' && href === '#fn:-') { | ||
tag2.setAttribute('href', href + n); | ||
} | ||
} | ||
} else if (tagName === 'li') { | ||
if (tag.id !== 'fn:-') continue; | ||
tag.id += n; | ||
tag2 = tag.lastChild; href = tag2.getAttribute('href'); | ||
if (tag2.nodeName === 'A' && href === '#fnref:-') { | ||
tag2.setAttribute('href', href + n); | ||
} | ||
} | ||
n++; | ||
} | ||
} | ||
fix_footnote('sup'); fix_footnote('li'); | ||
// add [] to footnote numbers | ||
d.querySelectorAll('sup[id^="fnref:"] > a.footnote-ref, a.footnote-ref > sup').forEach(el => { | ||
if (/^[0-9]+$/.test(el.innerText)) el.innerText = ' [' + el.innerText + ']'; | ||
}); | ||
// move the return symbol into the previous <p> | ||
@@ -29,0 +7,0 @@ d.querySelectorAll('.footnotes > ol > li > p ~ .footnote-return').forEach(el => { |
{ | ||
"name": "@xiee/utils", | ||
"version": "1.2.8", | ||
"version": "1.2.9", | ||
"description": "Miscellaneous tools and utilities to manipulate HTML pages", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -78,3 +78,4 @@ This repo contains miscellaneous tools and utilities written in JavaScript. They | ||
With `key-buttons.css`, the keys will be styled as boxes with shadows like | ||
buttons. | ||
buttons. You can learn more details [in this | ||
post](https://yihui.org/en/2023/02/key-buttons/). | ||
@@ -81,0 +82,0 @@ ## load-highlight.js |
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
102
23788
507