From 98cb2d3411d3a6f14f479c5013f17fb7a2c4dec3 Mon Sep 17 00:00:00 2001 From: G30 <50341825+silentoplayz@users.noreply.github.com> Date: Mon, 19 Jan 2026 04:58:48 -0500 Subject: [PATCH] feat: Add MATLAB syntax highlighting support for code blocks (#20773) * feat: Add MATLAB syntax highlighting support for code blocks Add MATLAB syntax highlighting support by fixing issues in both CodeEditor (editable) and CodeBlock (read-only) components. Changes: - CodeEditor.svelte: Added 'matlab' alias to CodeMirror's Octave language (MATLAB-compatible syntax) - CodeBlock.svelte: Fixed highlight.js usage to use highlight() directly when language is recognized, falling back to highlightAuto() only for unknown languages * revert: not needed --- src/lib/components/common/CodeEditor.svelte | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lib/components/common/CodeEditor.svelte b/src/lib/components/common/CodeEditor.svelte index 50c2a7cd1..ef8ed503d 100644 --- a/src/lib/components/common/CodeEditor.svelte +++ b/src/lib/components/common/CodeEditor.svelte @@ -104,6 +104,12 @@ }) ); + // Add 'matlab' alias to Octave language (MATLAB-compatible syntax) + const octaveLang = languages.find((l) => l.name === 'Octave'); + if (octaveLang && !octaveLang.alias.includes('matlab')) { + octaveLang.alias.push('matlab'); + } + const getLang = async () => { const language = languages.find((l) => l.alias.includes(lang)); return await language?.load();