File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -50,8 +50,12 @@ function transformMarkdownFiles(buffer: Buffer, file: any): string {
50
50
`<div material-docs-example="${ name } "></div>`
51
51
) ;
52
52
53
- content = content . replace ( LINK_PATTERN , ( match : string , pre : string , link : string ) =>
54
- `${ pre } href="${ fixMarkdownDocLinks ( link , file . path ) } "`
53
+ /* Replaces the URL in anchor elements inside of compiled markdown files. */
54
+ content = content . replace ( LINK_PATTERN , ( match : string , head : string , link : string ) =>
55
+ // The head is the first match of the RegExp and is necessary to ensure that the RegExp matches
56
+ // an anchor element. The head will be then used to re-create the existing anchor element.
57
+ // If the head is not prepended to the replaced value, then the first match will be lost.
58
+ `${ head } href="${ fixMarkdownDocLinks ( link , file . path ) } "`
55
59
) ;
56
60
57
61
return content ;
You can’t perform that action at this time.
0 commit comments