Skip to content

Commit

Permalink
chore: add support for lua, haskell style magic comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dotslashtarun committed Apr 6, 2023
1 parent 46d2aa2 commit 24cde7d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/docusaurus-theme-common/src/utils/codeBlockUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const commentPatterns = {
jsx: {start: '\\{\\s*\\/\\*', end: '\\*\\/\\s*\\}'},
bash: {start: '#', end: ''},
html: {start: '<!--', end: '-->'},
lua: {start: '--', end: ''},
};

type CommentType = keyof typeof commentPatterns;
Expand Down Expand Up @@ -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
return getCommentPattern(
Object.keys(commentPatterns) as CommentType[],
Object.keys(commentPatterns).filter((pattern) =>
!['lua'].includes(pattern)
) as CommentType[],
magicCommentDirectives,
);
}
Expand Down

0 comments on commit 24cde7d

Please sign in to comment.