mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-28 05:58:38 +02:00
feat(theme-common): code block MagicComments support for Lua/Haskell -- and WebAssembly ;; (#8870)
Co-authored-by: Tarun Chauhan <tarun.chauhan@tripjack.com> Co-authored-by: Sébastien Lorber <slorber@users.noreply.github.com>
This commit is contained in:
parent
08cfe4e3c9
commit
b169404efd
2 changed files with 61 additions and 2 deletions
|
@ -19,6 +19,8 @@ const commentPatterns = {
|
|||
jsx: {start: '\\{\\s*\\/\\*', end: '\\*\\/\\s*\\}'},
|
||||
bash: {start: '#', end: ''},
|
||||
html: {start: '<!--', end: '-->'},
|
||||
lua: {start: '--', end: ''},
|
||||
wasm: {start: '\\;\\;', end: ''},
|
||||
};
|
||||
|
||||
type CommentType = keyof typeof commentPatterns;
|
||||
|
@ -83,10 +85,20 @@ function getAllMagicCommentDirectiveStyles(
|
|||
// Text uses HTML, front matter uses bash
|
||||
return getCommentPattern(['html', 'jsx', 'bash'], magicCommentDirectives);
|
||||
|
||||
case 'lua':
|
||||
case 'haskell':
|
||||
case 'sql':
|
||||
return getCommentPattern(['lua'], magicCommentDirectives);
|
||||
|
||||
case 'wasm':
|
||||
return getCommentPattern(['wasm'], magicCommentDirectives);
|
||||
|
||||
default:
|
||||
// All comment types
|
||||
// All comment types except lua and wasm
|
||||
return getCommentPattern(
|
||||
Object.keys(commentPatterns) as CommentType[],
|
||||
Object.keys(commentPatterns).filter(
|
||||
(pattern) => !['lua', 'wasm'].includes(pattern),
|
||||
) as CommentType[],
|
||||
magicCommentDirectives,
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue