File tree 1 file changed +3
-10
lines changed 1 file changed +3
-10
lines changed Original file line number Diff line number Diff line change @@ -4,19 +4,12 @@ var visit = require('unist-util-visit')
4
4
5
5
module . exports = shiftHeading
6
6
7
- var floor = Math . floor
8
- var min = 1
9
- var max = 6
10
-
11
- // Character codes.
12
- var digit0 = 48
13
-
14
7
function shiftHeading ( tree , shift ) {
15
8
if (
16
9
typeof shift !== 'number' ||
17
10
! shift ||
18
11
! isFinite ( shift ) ||
19
- floor ( shift ) !== shift
12
+ Math . floor ( shift ) !== shift
20
13
) {
21
14
throw new Error ( 'Expected a non-null finite integer, not `' + shift + '`' )
22
15
}
@@ -37,8 +30,8 @@ function shiftHeading(tree, shift) {
37
30
name === 'h5' ||
38
31
name === 'h6'
39
32
) {
40
- rank = name . charCodeAt ( 1 ) - digit0 + shift
41
- node . tagName = 'h' + ( rank > max ? max : rank < min ? min : rank )
33
+ rank = name . charCodeAt ( 1 ) - 48 /* `0` */ + shift
34
+ node . tagName = 'h' + ( rank > 6 ? 6 : rank < 1 ? 1 : rank )
42
35
}
43
36
}
44
37
}
You can’t perform that action at this time.
0 commit comments