File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 1
1
/**
2
2
* @typedef {import('hast').Root } Root
3
- * @typedef {Root['children'][number]|Root } Node
3
+ * @typedef {import('hast').Content } Content
4
+ */
5
+
6
+ /**
7
+ * @typedef {Content | Root } Node
4
8
*/
5
9
6
10
import { headingRank } from 'hast-util-heading-rank'
7
11
import { visit } from 'unist-util-visit'
8
12
13
+ // To do next major: don’t return node.
9
14
/**
15
+ * Change the rank of all headings (`h1` to `h6`) in `tree`.
16
+ *
17
+ * Mutates the tree.
18
+ * Caps the rank so that shifting would not create invalid headings (so no `h0` or
19
+ * `h7`).
20
+ *
10
21
* @template {Node} T
22
+ * Node type.
11
23
* @param {T } tree
24
+ * Tree to change.
12
25
* @param {number } shift
26
+ * Non-null finite integer to use to shift ranks.
13
27
* @returns {T }
28
+ * Given, modified, tree.
14
29
*/
15
30
export function shiftHeading ( tree , shift ) {
16
31
if (
Original file line number Diff line number Diff line change @@ -128,6 +128,7 @@ There is no default export.
128
128
### ` shiftHeading(tree, shift) `
129
129
130
130
Change the rank of all headings (` h1 ` to ` h6 ` ) in ` tree ` .
131
+
131
132
Mutates the tree.
132
133
Caps the rank so that shifting would not create invalid headings (so no ` h0 ` or
133
134
` h7 ` ).
You can’t perform that action at this time.
0 commit comments