@mehm8128/rehype-toc 1.1.0 → 1.1.1

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/dist/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
- import { Element, Root } from "hast";
1
+ import { Root } from "hast";
2
2
 
3
3
  //#region src/index.d.ts
4
- declare const rehypeCollapsableToc: () => (tree: Root) => void;
5
- declare const visitorCallback: (node: Element, rootUlElement: Element) => void;
4
+ declare const rehypeCollapsibleToc: () => (tree: Root) => void;
6
5
  //#endregion
7
- export { rehypeCollapsableToc, visitorCallback };
6
+ export { rehypeCollapsibleToc };
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { visit } from "unist-util-visit";
2
2
 
3
3
  //#region src/index.ts
4
- const rehypeCollapsableToc = () => {
4
+ const rehypeCollapsibleToc = () => {
5
5
  return (tree) => {
6
6
  const rootUlElement = {
7
7
  type: "element",
@@ -12,7 +12,7 @@ const rehypeCollapsableToc = () => {
12
12
  visit(tree, "element", (node) => {
13
13
  visitorCallback(node, rootUlElement);
14
14
  });
15
- const detailsElement = createCollapsableToc(rootUlElement);
15
+ const detailsElement = createCollapsibleToc(rootUlElement);
16
16
  tree.children.unshift(detailsElement);
17
17
  };
18
18
  };
@@ -44,8 +44,8 @@ const searchSameLevelUlElement = (rootUlElement, level) => {
44
44
  const headingTextElement = assertElementText(headingAnchorElement.children[0]);
45
45
  const rootElementHeadingLevel = getHeadingLevelFromText(headingTextElement);
46
46
  if (rootElementHeadingLevel === level) return rootLiElement;
47
- if (rootLiElement.children[1] === void 0) return;
48
- const childUlElement = assertElementNode(rootLiElement.children[1]);
47
+ const childUlElement = assertElementNodeList(rootLiElement.children)[1];
48
+ if (childUlElement === void 0) return;
49
49
  return searchSameLevelUlElement(assertElementNodeList(childUlElement.children), level);
50
50
  };
51
51
  /**
@@ -53,8 +53,8 @@ const searchSameLevelUlElement = (rootUlElement, level) => {
53
53
  */
54
54
  const getDeepestLiElement = (rootUlElement) => {
55
55
  const rootLiElement = assertElementNode(rootUlElement[rootUlElement.length - 1]);
56
- if (!rootLiElement.children[1]) return rootLiElement;
57
- const olElement = assertElementNode(rootLiElement.children[1]);
56
+ const olElement = assertElementNodeList(rootLiElement.children)[1];
57
+ if (!olElement) return rootLiElement;
58
58
  return getDeepestLiElement(assertElementNodeList(olElement.children));
59
59
  };
60
60
  const getHeadingLevelFromElement = (headingElement) => {
@@ -94,7 +94,7 @@ const createListItemElement = (node) => {
94
94
  children: [anchorElement]
95
95
  };
96
96
  };
97
- const createCollapsableToc = (rootUlElement) => {
97
+ const createCollapsibleToc = (rootUlElement) => {
98
98
  const summaryElement = {
99
99
  type: "element",
100
100
  tagName: "summary",
@@ -126,4 +126,4 @@ const assertElementText = (node) => {
126
126
  };
127
127
 
128
128
  //#endregion
129
- export { rehypeCollapsableToc, visitorCallback };
129
+ export { rehypeCollapsibleToc };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mehm8128/rehype-toc",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",