From a95cb7b6ca973efd61107e5e279a3ad2fbf0ac39 Mon Sep 17 00:00:00 2001 From: Riley Bruins Date: Fri, 27 Sep 2024 16:46:57 -0700 Subject: [PATCH] fix(previewer): mark @example code blocks as typescript When interpreting the preview result as Markdown, it is quite helpful to have the `typescript` language annotation before `@example` code blocks because it will give code highlights and make it more clear that this is an example of code rather than just raw text. --- src/utils/previewer.test.ts | 4 ++-- src/utils/previewer.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/previewer.test.ts b/src/utils/previewer.test.ts index fe2b06ea..0689980d 100644 --- a/src/utils/previewer.test.ts +++ b/src/utils/previewer.test.ts @@ -99,7 +99,7 @@ describe('typescript.previewer', () => { text: 'code();', }, ], noopToResource), - ).toBe('*@example* \n```\ncode();\n```', + ).toBe('*@example* \n```typescript\ncode();\n```', ); }); @@ -123,7 +123,7 @@ describe('typescript.previewer', () => { text: 'Not code\ncode();', }, ], noopToResource), - ).toBe('*@example* \nNot code\n```\ncode();\n```', + ).toBe('*@example* \nNot code\n```typescript\ncode();\n```', ); }); diff --git a/src/utils/previewer.ts b/src/utils/previewer.ts index dd32ef2e..f86bbbdb 100644 --- a/src/utils/previewer.ts +++ b/src/utils/previewer.ts @@ -52,7 +52,7 @@ function getTagBodyText( if (/^\s*[~`]{3}/m.test(text)) { return text; } - return '```\n' + text + '\n```'; + return '```typescript\n' + text + '\n```'; } const text = convertLinkTags(tag.text, filePathConverter);