File tree 2 files changed +5
-3
lines changed
2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,8 @@ function tocPlugin (md, options) {
35
35
level : 1 ,
36
36
listType : 'ol' ,
37
37
format : undefined ,
38
- callback : undefined /* function(html, ast) {} */
38
+ callback : undefined /* function(html, ast) {} */ ,
39
+ allowedTokenTypes : [ "text" , "code_inline" ]
39
40
} , options )
40
41
41
42
let ast
@@ -156,7 +157,7 @@ function tocPlugin (md, options) {
156
157
const key = (
157
158
tokens [ i + 1 ]
158
159
. children
159
- . filter ( function ( token ) { return token . type === 'text' || token . type === 'code_inline' } )
160
+ . filter ( function ( token ) { return options . allowedTokenTypes . indexOf ( token . type ) !== - 1 } )
160
161
. reduce ( function ( s , t ) { return s + t . content } , '' )
161
162
)
162
163
Original file line number Diff line number Diff line change @@ -13,7 +13,8 @@ declare module 'markdown-it-toc-done-right' {
13
13
level : number | number [ ]
14
14
listType : 'ol' | 'ul'
15
15
format : ( s : string ) => string
16
- callback : ( tocCode : string , ast : TocAst ) => void
16
+ callback : ( tocCode : string , ast : TocAst ) => void ,
17
+ allowedTokenTypes : string [ ]
17
18
}
18
19
19
20
export interface TocAst {
You can’t perform that action at this time.
0 commit comments