File tree Expand file tree Collapse file tree 2 files changed +8
-15
lines changed Expand file tree Collapse file tree 2 files changed +8
-15
lines changed Original file line number Diff line number Diff line change 1
1
/**
2
- * @typedef {Root['children'][number]|Root } Node
3
2
* @typedef {import('hast').Root } Root
4
- * @typedef {import('hast').Element } Element
5
- * @typedef {import('unist-util-visit').Visitor<Element> } VisitElement
3
+ * @typedef {Root['children'][number]|Root } Node
6
4
*/
7
5
8
6
import { headingRank } from 'hast-util-heading-rank'
@@ -24,19 +22,14 @@ export function shiftHeading(tree, shift) {
24
22
throw new Error ( 'Expected a non-null finite integer, not `' + shift + '`' )
25
23
}
26
24
27
- visit (
28
- tree ,
29
- 'element' ,
30
- /** @type {VisitElement } */
31
- ( node ) => {
32
- let rank = headingRank ( node )
25
+ visit ( tree , 'element' , ( node ) => {
26
+ let rank = headingRank ( node )
33
27
34
- if ( rank ) {
35
- rank += shift
36
- node . tagName = 'h' + ( rank > 6 ? 6 : rank < 1 ? 1 : rank )
37
- }
28
+ if ( rank ) {
29
+ rank += shift
30
+ node . tagName = 'h' + ( rank > 6 ? 6 : rank < 1 ? 1 : rank )
38
31
}
39
- )
32
+ } )
40
33
41
34
return tree
42
35
}
Original file line number Diff line number Diff line change 38
38
"dependencies" : {
39
39
"@types/hast" : " ^2.0.0" ,
40
40
"hast-util-heading-rank" : " ^2.0.0" ,
41
- "unist-util-visit" : " ^3 .0.0"
41
+ "unist-util-visit" : " ^4 .0.0"
42
42
},
43
43
"devDependencies" : {
44
44
"@types/tape" : " ^4.0.0" ,
You can’t perform that action at this time.
0 commit comments