Skip to content

Commit 0bc06ab

Browse files
committed
Adds a comment
1 parent 1b05432 commit 0bc06ab

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

tools/gulp/tasks/docs.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,12 @@ function transformMarkdownFiles(buffer: Buffer, file: any): string {
5050
`<div material-docs-example="${name}"></div>`
5151
);
5252

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)}"`
5559
);
5660

5761
return content;

0 commit comments

Comments
 (0)