From eb226ae32e8e8cb28d4fd77d57238b6a508c11f5 Mon Sep 17 00:00:00 2001 From: Gerrit Birkeland Date: Fri, 10 Sep 2021 01:22:43 +0000 Subject: [PATCH] Fix codeblock detection to catch blocks not on first Lines --- .../src/utils/previewer.ts | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/extensions/typescript-language-features/src/utils/previewer.ts b/extensions/typescript-language-features/src/utils/previewer.ts index 93a88382500d46..78fd2a202d57f6 100644 --- a/extensions/typescript-language-features/src/utils/previewer.ts +++ b/extensions/typescript-language-features/src/utils/previewer.ts @@ -39,9 +39,9 @@ function getTagBodyText( return undefined; } - // Convert to markdown code block if it is not already one + // Convert to markdown code block if it does not already contain one function makeCodeblock(text: string): string { - if (text.match(/^\s*[~`]{3}/g)) { + if (text.match(/^\s*[~`]{3}/m)) { return text; } return '```\n' + text + '\n```'; @@ -49,14 +49,6 @@ function getTagBodyText( const text = convertLinkTags(tag.text, filePathConverter); switch (tag.name) { - case 'example': - // check for caption tags, fix for #79704 - const captionTagMatches = text.match(/(.*?)<\/caption>\s*(\r\n|\n)/); - if (captionTagMatches && captionTagMatches.index === 0) { - return captionTagMatches[1] + '\n\n' + makeCodeblock(text.substr(captionTagMatches[0].length)); - } else { - return makeCodeblock(text); - } case 'author': // fix obsucated email address, #80898 const emailMatch = text.match(/(.+)\s<([-.\w]+@[-.\w]+)>/); @@ -66,6 +58,7 @@ function getTagBodyText( } else { return `${emailMatch[1]} ${emailMatch[2]}`; } + case 'example': case 'default': return makeCodeblock(text); }