feat(theme-common): code block MagicComments support for TeX/LaTeX/Matlab (#8982)

Co-authored-by: Sébastien Lorber <slorber@users.noreply.github.com>
This commit is contained in:
JJ Style 2023-05-30 14:28:28 +01:00 committed by GitHub
parent 4f3901b932
commit 30a4181290
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 2 deletions

View file

@ -21,6 +21,7 @@ const commentPatterns = {
html: {start: '<!--', end: '-->'},
lua: {start: '--', end: ''},
wasm: {start: '\\;\\;', end: ''},
tex: {start: '%', end: ''},
};
type CommentType = keyof typeof commentPatterns;
@ -85,6 +86,11 @@ function getAllMagicCommentDirectiveStyles(
// Text uses HTML, front matter uses bash
return getCommentPattern(['html', 'jsx', 'bash'], magicCommentDirectives);
case 'tex':
case 'latex':
case 'matlab':
return getCommentPattern(['tex'], magicCommentDirectives);
case 'lua':
case 'haskell':
case 'sql':
@ -94,10 +100,11 @@ function getAllMagicCommentDirectiveStyles(
return getCommentPattern(['wasm'], magicCommentDirectives);
default:
// All comment types except lua and wasm
// All comment types except lua, wasm and matlab
return getCommentPattern(
Object.keys(commentPatterns).filter(
(pattern) => !['lua', 'wasm'].includes(pattern),
(pattern) =>
!['lua', 'wasm', 'tex', 'latex', 'matlab'].includes(pattern),
) as CommentType[],
magicCommentDirectives,
);