mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-24 11:58:31 -05:00
[GH-ISSUE #20719] issue: The MATLAB code block is not properly highlighted. #90012
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @17Reset on GitHub (Jan 16, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/20719
Check Existing Issues
Installation Method
Git Clone
Open WebUI Version
v0.7.2
Ollama Version (if applicable)
No response
Operating System
Ubuntu24.04
Browser (if applicable)
No response
Confirmation
README.md.Expected Behavior
Highlight MATLAB code
Actual Behavior
Unhighlighted MATLAB code
Steps to Reproduce
pass
Logs & Screenshots
Additional Information
No response
@owui-terminator[bot] commented on GitHub (Jan 16, 2026):
🔍 Similar Issues Found
I found some existing issues that might be related to this one. Please check if any of these are duplicates or contain helpful solutions:
#20632 issue: Inconsistent behavior when editing section breaks.
by jdwx • Jan 13, 2026 •
bug#20361 Issue: Large-scale model setting-related functionality fails.
by shentong0722 • Jan 04, 2026 •
bug💡 Tips:
This comment was generated automatically by a bot. Please react with a 👍 if this comment was helpful, or a 👎 if it was not.
@silentoplayz commented on GitHub (Jan 17, 2026):
I am able to reproduce this on the latest
devcommit. Syntax highlighting for MATLAB code blocks CAN be added (see below)!Root Cause
There are two separate issues preventing MATLAB syntax highlighting:
1. CodeEditor.svelte (editable code blocks)
The
CodeEditorcomponent uses CodeMirror for syntax highlighting. CodeMirror includes an Octave language (which is MATLAB-compatible), but it only registers'octave'as an alias—not'matlab'. The fix is to add'matlab'as an alias:2. CodeBlock.svelte (read-only code blocks)
The non-editable code path uses highlight.js, which does support MATLAB. However, the current code incorrectly uses
highlightAuto()with the language's aliases as hints:hljs.highlightAuto(code, hljs.getLanguage(lang)?.aliases).valueThe problem is that
hljs.getLanguage('matlab')?.aliasesreturnsundefined(MATLAB has no aliases defined), so highlightAuto() receives no hints and may fail to detect MATLAB. The fix is to usehighlight()directly when the language is recognized:End Result
Happy to submit a PR if this approach looks good!
@silentoplayz commented on GitHub (Jan 19, 2026):
Solved with https://github.com/open-webui/open-webui/pull/20773#event-22133767118 on the
devbranch!