@xiee/utils 1.3.14 → 1.3.16

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.
@@ -1,13 +1,12 @@
1
1
  (function(d) {
2
2
  const r = /^(https?:)?\/\//;
3
3
  d.querySelectorAll('a').forEach(a => {
4
+ if (!r.test(a.getAttribute('href'))) return;
4
5
  // add _blank target to external links
5
- if (r.test(a.getAttribute('href'))) {
6
- a.target = '_blank';
7
- }
6
+ a.target = '_blank';
8
7
  // shorten bare links
9
8
  if (a.childElementCount === 0) {
10
- a.innerText = a.innerText.replace(r, '').replace(/#.*$/, '');
9
+ a.innerText = a.innerText.replace(r, '').replace(/(.+)#.*$/, '$1');
11
10
  }
12
11
  })
13
12
  })(document);
@@ -1 +1 @@
1
- !function(e){const t=/^(https?:)?\/\//;e.querySelectorAll("a").forEach((e=>{t.test(e.getAttribute("href"))&&(e.target="_blank"),0===e.childElementCount&&(e.innerText=e.innerText.replace(t,"").replace(/#.*$/,""))}))}(document);
1
+ !function(e){const t=/^(https?:)?\/\//;e.querySelectorAll("a").forEach((e=>{t.test(e.getAttribute("href"))&&(e.target="_blank",0===e.childElementCount&&(e.innerText=e.innerText.replace(t,"").replace(/(.+)#.*$/,"$1")))}))}(document);
package/js/math-code.js CHANGED
@@ -1,5 +1,8 @@
1
+ // <code>$math$</code> to \(math\), and <code>$$math$$</code> to $$math$$:
2
+ // https://yihui.org/en/2018/07/latex-math-markdown/
1
3
  [...document.getElementsByTagName('code')].forEach(code => {
2
- if (code.parentNode.tagName === 'PRE' || code.childElementCount > 0) return;
4
+ // skip <pre> tags and <code> that has children or the nolatex class
5
+ if (code.parentNode.tagName === 'PRE' || code.childElementCount > 0 || code.classList.contains('nolatex')) return;
3
6
  let text = code.textContent;
4
7
  if (/^\$[^$]/.test(text) && /[^$]\$$/.test(text)) {
5
8
  text = text.replace(/^\$/, '\\(').replace(/\$$/, '\\)');
@@ -1 +1 @@
1
- [...document.getElementsByTagName("code")].forEach((e=>{if("PRE"===e.parentNode.tagName||e.childElementCount>0)return;let t=e.textContent;/^\$[^$]/.test(t)&&/[^$]\$$/.test(t)&&(t=t.replace(/^\$/,"\\(").replace(/\$$/,"\\)"),e.textContent=t),(/^\\\((.|\s)+\\\)$/.test(t)||/^\\\[(.|\s)+\\\]$/.test(t)||/^\$(.|\s)+\$$/.test(t)||/^\\begin\{([^}]+)\}(.|\s)+\\end\{[^}]+\}$/.test(t))&&(e.outerHTML=e.innerHTML)}));
1
+ [...document.getElementsByTagName("code")].forEach((t=>{if("PRE"===t.parentNode.tagName||t.childElementCount>0||t.classList.contains("nolatex"))return;let e=t.textContent;/^\$[^$]/.test(e)&&/[^$]\$$/.test(e)&&(e=e.replace(/^\$/,"\\(").replace(/\$$/,"\\)"),t.textContent=e),(/^\\\((.|\s)+\\\)$/.test(e)||/^\\\[(.|\s)+\\\]$/.test(e)||/^\$(.|\s)+\$$/.test(e)||/^\\begin\{([^}]+)\}(.|\s)+\\end\{[^}]+\}$/.test(e))&&(t.outerHTML=t.innerHTML)}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xiee/utils",
3
- "version": "1.3.14",
3
+ "version": "1.3.16",
4
4
  "description": "Miscellaneous tools and utilities to manipulate HTML pages",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"