[GH-ISSUE #20719] issue: The MATLAB code block is not properly highlighted. #90012

Closed
opened 2026-05-15 15:05:23 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @17Reset on GitHub (Jan 16, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/20719

Check Existing Issues

  • I have searched for any existing and/or related issues.
  • I have searched for any existing and/or related discussions.
  • I have also searched in the CLOSED issues AND CLOSED discussions and found no related items (your issue might already be addressed on the development branch!).
  • I am using the latest version of Open WebUI.

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

  • I have read and followed all instructions in README.md.
  • I am using the latest version of both Open WebUI and Ollama.
  • I have included the browser console logs.
  • I have included the Docker container logs.
  • I have provided every relevant configuration, setting, and environment variable used in my setup.
  • I have clearly listed every relevant configuration, custom setting, environment variable, and command-line option that influences my setup (such as Docker Compose overrides, .env values, browser settings, authentication configurations, etc).
  • I have documented step-by-step reproduction instructions that are precise, sequential, and leave nothing to interpretation. My steps:
  • Start with the initial platform/version/OS and dependencies used,
  • Specify exact install/launch/configure commands,
  • List URLs visited, user input (incl. example values/emails/passwords if needed),
  • Describe all options and toggles enabled or changed,
  • Include any files or environmental changes,
  • Identify the expected and actual result at each stage,
  • Ensure any reasonably skilled user can follow and hit the same issue.

Expected Behavior

Highlight MATLAB code

Actual Behavior

Unhighlighted MATLAB code

Steps to Reproduce

pass

Logs & Screenshots

Image

Additional Information

No response

Originally created by @17Reset on GitHub (Jan 16, 2026). Original GitHub issue: https://github.com/open-webui/open-webui/issues/20719 ### Check Existing Issues - [x] I have searched for any existing and/or related issues. - [x] I have searched for any existing and/or related discussions. - [x] I have also searched in the CLOSED issues AND CLOSED discussions and found no related items (your issue might already be addressed on the development branch!). - [x] I am using the latest version of Open WebUI. ### 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 - [x] I have read and followed all instructions in `README.md`. - [x] I am using the latest version of **both** Open WebUI and Ollama. - [x] I have included the browser console logs. - [x] I have included the Docker container logs. - [x] I have **provided every relevant configuration, setting, and environment variable used in my setup.** - [x] I have clearly **listed every relevant configuration, custom setting, environment variable, and command-line option that influences my setup** (such as Docker Compose overrides, .env values, browser settings, authentication configurations, etc). - [x] I have documented **step-by-step reproduction instructions that are precise, sequential, and leave nothing to interpretation**. My steps: - Start with the initial platform/version/OS and dependencies used, - Specify exact install/launch/configure commands, - List URLs visited, user input (incl. example values/emails/passwords if needed), - Describe all options and toggles enabled or changed, - Include any files or environmental changes, - Identify the expected and actual result at each stage, - Ensure any reasonably skilled user can follow and hit the same issue. ### Expected Behavior Highlight MATLAB code ### Actual Behavior Unhighlighted MATLAB code ### Steps to Reproduce pass ### Logs & Screenshots <img width="738" height="335" alt="Image" src="https://github.com/user-attachments/assets/62ecae1b-97b3-4f4a-8c5b-900d534623fa" /> ### Additional Information _No response_
GiteaMirror added the bugconfirmed issue labels 2026-05-15 15:05:24 -05:00
Author
Owner

@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:

  1. #20632 issue: Inconsistent behavior when editing section breaks.
    by jdwx • Jan 13, 2026 • bug

  2. #20361 Issue: Large-scale model setting-related functionality fails.
    by shentong0722 • Jan 04, 2026 • bug


💡 Tips:

  • If this is a duplicate, please consider closing this issue and adding any additional details to the existing one
  • If you found a solution in any of these issues, please share it here to help others

This comment was generated automatically by a bot. Please react with a 👍 if this comment was helpful, or a 👎 if it was not.

<!-- gh-comment-id:3758685357 --> @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: 1. [#20632](https://github.com/open-webui/open-webui/issues/20632) **issue: Inconsistent behavior when editing section breaks.** *by jdwx • Jan 13, 2026 • `bug`* 2. [#20361](https://github.com/open-webui/open-webui/issues/20361) **Issue: Large-scale model setting-related functionality fails.** *by shentong0722 • Jan 04, 2026 • `bug`* --- 💡 **Tips:** - If this is a duplicate, please consider closing this issue and adding any additional details to the existing one - If you found a solution in any of these issues, please share it here to help others *This comment was generated automatically by a bot.* Please react with a 👍 if this comment was helpful, or a 👎 if it was not.
Author
Owner

@silentoplayz commented on GitHub (Jan 17, 2026):

I am able to reproduce this on the latest dev commit. 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 CodeEditor component 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:

// 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');
}
Image

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).value

The problem is that hljs.getLanguage('matlab')?.aliases returns undefined (MATLAB has no aliases defined), so highlightAuto() receives no hints and may fail to detect MATLAB. The fix is to use highlight() directly when the language is recognized:

(hljs.getLanguage(lang)
    ? hljs.highlight(code, { language: lang })
    : hljs.highlightAuto(code)
).value || code
Image

End Result

Image

Happy to submit a PR if this approach looks good!

<!-- gh-comment-id:3764220473 --> @silentoplayz commented on GitHub (Jan 17, 2026): I am able to reproduce this on the latest `dev` commit. 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 `CodeEditor` component 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: ```js // 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'); } ``` <img width="2560" height="372" alt="Image" src="https://github.com/user-attachments/assets/15092d1f-6d3e-4055-931d-a97baf8b4856" /> ### 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).value` The problem is that `hljs.getLanguage('matlab')?.aliases` returns `undefined` (MATLAB has no aliases defined), so highlightAuto() receives no hints and may fail to detect MATLAB. The fix is to use `highlight()` directly when the language is recognized: ```js (hljs.getLanguage(lang) ? hljs.highlight(code, { language: lang }) : hljs.highlightAuto(code) ).value || code ``` <img width="2560" height="329" alt="Image" src="https://github.com/user-attachments/assets/0de8dae6-46e7-4214-aec3-23a9e19085ea" /> ## End Result <img width="2560" height="1271" alt="Image" src="https://github.com/user-attachments/assets/e5d1263d-268a-4cd1-a6b2-a1ddf49fdefc" /> Happy to submit a PR if this approach looks good!
Author
Owner

@silentoplayz commented on GitHub (Jan 19, 2026):

Solved with https://github.com/open-webui/open-webui/pull/20773#event-22133767118 on the dev branch!

<!-- gh-comment-id:3767460646 --> @silentoplayz commented on GitHub (Jan 19, 2026): Solved with https://github.com/open-webui/open-webui/pull/20773#event-22133767118 on the `dev` branch!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#90012