File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,10 @@ function walk(dir) {
18
18
return results ;
19
19
}
20
20
21
+ function stripLinks ( line ) {
22
+ return line . replace ( / \[ ( [ ^ \] ] + ) \] \( [ ^ ) ] + \) / , ( match , p1 ) => p1 ) ;
23
+ }
24
+
21
25
function addHeaderID ( line , slugger ) {
22
26
// check if we're a header at all
23
27
if ( ! line . startsWith ( '#' ) ) {
@@ -27,7 +31,10 @@ function addHeaderID(line, slugger) {
27
31
if ( / \{ # [ ^ } ] + \} / . test ( line ) ) {
28
32
return line ;
29
33
}
30
- const headingText = line . slice ( line . indexOf ( ' ' ) ) . trim ( ) ;
34
+ if ( / \[ [ ^ \] ] + \] / . test ( line ) ) {
35
+ console . log ( line ) ;
36
+ }
37
+ const headingText = stripLinks ( line . slice ( line . indexOf ( ' ' ) ) . trim ( ) ) ;
31
38
const headingLevel = line . slice ( 0 , line . indexOf ( ' ' ) ) ;
32
39
return `${ headingLevel } ${ headingText } {#${ slugger . slug ( headingText ) } }` ;
33
40
}
You can’t perform that action at this time.
0 commit comments