From 0bc06abf09b3fd36f8017b305deb052ddfaba979 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Wed, 25 Jan 2017 19:33:31 +0100 Subject: [PATCH] Adds a comment --- tools/gulp/tasks/docs.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/gulp/tasks/docs.ts b/tools/gulp/tasks/docs.ts index 3d4bbb43a011..ace221fde277 100644 --- a/tools/gulp/tasks/docs.ts +++ b/tools/gulp/tasks/docs.ts @@ -50,8 +50,12 @@ function transformMarkdownFiles(buffer: Buffer, file: any): string { `
` ); - content = content.replace(LINK_PATTERN, (match: string, pre: string, link: string) => - `${pre} href="${fixMarkdownDocLinks(link, file.path)}"` + /* Replaces the URL in anchor elements inside of compiled markdown files. */ + content = content.replace(LINK_PATTERN, (match: string, head: string, link: string) => + // The head is the first match of the RegExp and is necessary to ensure that the RegExp matches + // an anchor element. The head will be then used to re-create the existing anchor element. + // If the head is not prepended to the replaced value, then the first match will be lost. + `${head} href="${fixMarkdownDocLinks(link, file.path)}"` ); return content;