From 66eec0c7d42f87f6c2363fb52076f1a249689e91 Mon Sep 17 00:00:00 2001 From: Tarun Chauhan Date: Thu, 6 Apr 2023 22:24:50 +0530 Subject: [PATCH] chore: add support for lua, haskell style magic comments --- .../src/utils/codeBlockUtils.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/docusaurus-theme-common/src/utils/codeBlockUtils.ts b/packages/docusaurus-theme-common/src/utils/codeBlockUtils.ts index 5acef72cf38aa..46fbd17711982 100644 --- a/packages/docusaurus-theme-common/src/utils/codeBlockUtils.ts +++ b/packages/docusaurus-theme-common/src/utils/codeBlockUtils.ts @@ -19,6 +19,7 @@ const commentPatterns = { jsx: {start: '\\{\\s*\\/\\*', end: '\\*\\/\\s*\\}'}, bash: {start: '#', end: ''}, html: {start: ''}, + lua: {start: '--', end: ''}, }; type CommentType = keyof typeof commentPatterns; @@ -83,10 +84,16 @@ function getAllMagicCommentDirectiveStyles( // Text uses HTML, front matter uses bash return getCommentPattern(['html', 'jsx', 'bash'], magicCommentDirectives); + case 'lua': + case 'haskell': + return getCommentPattern(['lua'], magicCommentDirectives); + default: - // All comment types + // All comment types except Lua and Haskell return getCommentPattern( - Object.keys(commentPatterns) as CommentType[], + Object.keys(commentPatterns).filter((pattern) => + !['lua', 'haskell'].includes(pattern) + ) as CommentType[], magicCommentDirectives, ); }