@xiee/utils 1.3.11 → 1.3.12

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.
package/README.md CHANGED
@@ -56,6 +56,12 @@ Add `[ ]` to footnote numbers and move the return symbols in footnotes.
56
56
 
57
57
  Fix the table of contents generated by lower versions of Hugo.
58
58
 
59
+ ## fullwidth.js
60
+
61
+ Find `<pre>` and `<table>` elements and add the `fullwidth` class to them if
62
+ they are too wide, so they can be styled differently (e.g., [full
63
+ bleed](https://css-tricks.com/full-bleed/)).
64
+
59
65
  ## hash-notes.js
60
66
 
61
67
  Convert HTML comments of the form `<!--# comments -->` to
@@ -93,6 +99,10 @@ expressions (by default, MathJax ignores math in `<code>`).
93
99
  Add the `nohighlight` class to `<code>` in `<pre>` when it does not have a
94
100
  class, so that highlight.js will not try to syntax highlight the code in it.
95
101
 
102
+ ## number-sections.js
103
+
104
+ Find all section headings (`h1` - `h6`) and number them.
105
+
96
106
  ## render-katex.js
97
107
 
98
108
  Simply run `renderMathInElement(document.body)` to render math expression using
@@ -102,3 +112,12 @@ KaTeX's auto-render extension.
102
112
 
103
113
  Right-align a `<blockquote>` footer if the footer is a `<p>` that starts with
104
114
  the em-dash.
115
+
116
+ ## toc.js
117
+
118
+ Automatically build a table of contents (TOC) from all section headings.
119
+
120
+ ## toc-highlight.js
121
+
122
+ Add a class `active` to the TOC item (`<a>`) corresponding to the section
123
+ heading that is currently being scrolled into view.
@@ -0,0 +1,21 @@
1
+ // highlight a TOC item when scrolling to a corresponding section heading
2
+ (function(d) {
3
+ // assume TOC has these possible IDs (we can also consider other selectors)
4
+ const toc = d.querySelector('#TableOfContents, #TOC');
5
+ if (!toc) return;
6
+ const links = toc.querySelectorAll('a');
7
+ if (!links.length) return;
8
+
9
+ // create a new Intersection Observer instance
10
+ const observer = new IntersectionObserver(els => els.forEach(el => {
11
+ const id = el.target.id;
12
+ id && el.isIntersecting && links.forEach(a => {
13
+ a.classList[(a.getAttribute('href') === '#' + id) ? 'add' : 'remove']('active');
14
+ });
15
+ }));
16
+
17
+ // observe all section headings
18
+ d.querySelectorAll('h1,h2,h3,h4,h5,h6').forEach(h => {
19
+ h.nodeType === 1 && observer.observe(h);
20
+ });
21
+ })(document);
@@ -0,0 +1 @@
1
+ !function(e){const t=e.querySelector("#TableOfContents, #TOC");if(!t)return;const r=t.querySelectorAll("a");if(!r.length)return;const n=new IntersectionObserver((e=>e.forEach((e=>{const t=e.target.id;t&&e.isIntersecting&&r.forEach((e=>{e.classList[e.getAttribute("href")==="#"+t?"add":"remove"]("active")}))}))));e.querySelectorAll("h1,h2,h3,h4,h5,h6").forEach((e=>{1===e.nodeType&&n.observe(e)}))}(document);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xiee/utils",
3
- "version": "1.3.11",
3
+ "version": "1.3.12",
4
4
  "description": "Miscellaneous tools and utilities to manipulate HTML pages",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"