Add new Language-Highlighting-Support for Scheme or Racket #3433

Closed
opened 2026-02-05 06:42:08 +03:00 by OVERLORD · 10 comments
Owner

Originally created by @ecevitkarakus on GitHub (Jan 9, 2023).

Attempted Debugging

  • I have read the debugging page

Searched GitHub Issues

  • I have searched GitHub for the issue.

Describe the Scenario

Hello Book-Stack-Experts,

I have this question: how it is possible to add Syntax-highlighting for a new Language (Sheme or Racket Code) in the Code-Block?

I know, that there is a Scheme-Mode for code-mirror, but it is not active or integrated in Bookstack.

Thanks a lot.
EK

Exact BookStack Version

BookStack v22.09.1

Log Content

No response

PHP Version

?? I have now now access to the command line

Hosting Environment

self hosted,
Proxmox LXC

Originally created by @ecevitkarakus on GitHub (Jan 9, 2023). ### Attempted Debugging - [X] I have read the debugging page ### Searched GitHub Issues - [X] I have searched GitHub for the issue. ### Describe the Scenario Hello Book-Stack-Experts, I have this question: how it is possible to add Syntax-highlighting for a new Language (Sheme or Racket Code) in the Code-Block? I know, that there is a Scheme-Mode for code-mirror, but it is not active or integrated in Bookstack. Thanks a lot. EK ### Exact BookStack Version BookStack v22.09.1 ### Log Content _No response_ ### PHP Version ?? I have now now access to the command line ### Hosting Environment self hosted, Proxmox LXC
OVERLORD added the 🐕 Support label 2026-02-05 06:42:08 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Jan 10, 2023):

For reference, CM5 scheme mode: https://codemirror.net/5/mode/scheme/index.html
Does not seem to be a built-in racket mode.

@ssddanbrown commented on GitHub (Jan 10, 2023): For reference, CM5 scheme mode: https://codemirror.net/5/mode/scheme/index.html Does not seem to be a built-in racket mode.
Author
Owner

@ssddanbrown commented on GitHub (Jan 26, 2023):

Scheme support added in 25bdd71477, will be part of the next feature release.
Thanks for the request @ecevitkarakus.

@ssddanbrown commented on GitHub (Jan 26, 2023): Scheme support added in 25bdd714771a269d369e1702d2b6d2e6becbaf02, will be part of the next feature release. Thanks for the request @ecevitkarakus.
Author
Owner

@medpower commented on GitHub (Sep 26, 2023):

@ssddanbrown, thanks for this great sharing, I did have a similar question about how to add additional language support including R and SAS, I noticed the latest version v23.08.3 changed the folder structure and tried to import the R and SAS and added them in the modeMap as well (might be in the wrong way), but seems not work, although the options could be displayed in the window after the updates of the corresponding view page.

import {php} from '@codemirror/lang-php';
import {sas} from '@codemirror/lang-sas';
import {r} from '@codemirror/lang-r';
r: () => legacyLoad('r'),
 rb: () => legacyLoad('ruby'),
 rs: () => legacyLoad('rust'),
 ruby: () => legacyLoad('ruby'),
 rust: () => legacyLoad('rust'),
 sas: () => legacyLoad('sas'),

Could you please advise how to fix it with the latest version? Thanks a lot in advance!

Regards,
Stanley

@medpower commented on GitHub (Sep 26, 2023): @ssddanbrown, thanks for this great sharing, I did have a similar question about how to add additional language support including R and SAS, I noticed the latest version v23.08.3 changed the folder structure and tried to import the R and SAS and added them in the modeMap as well (might be in the wrong way), but seems not work, although the options could be displayed in the window after the updates of the corresponding view page. ``` import {php} from '@codemirror/lang-php'; import {sas} from '@codemirror/lang-sas'; import {r} from '@codemirror/lang-r'; ``` ``` r: () => legacyLoad('r'), rb: () => legacyLoad('ruby'), rs: () => legacyLoad('rust'), ruby: () => legacyLoad('ruby'), rust: () => legacyLoad('rust'), sas: () => legacyLoad('sas'), ``` Could you please advise how to fix it with the latest version? Thanks a lot in advance! Regards, Stanley
Author
Owner

@ssddanbrown commented on GitHub (Sep 26, 2023):

@medpower

import {sas} from '@codemirror/lang-sas';
import {r} from '@codemirror/lang-r';

I'm not sure those packages exist at all, were you loading via these before? Where version of BookStack were you on before? Was this working before?

If you're loading via a legacy mode, via the legacyMode function, then your language will need to be exported in this file:

fa6fcc1c1c/resources/js/code/legacy-modes.mjs

@ssddanbrown commented on GitHub (Sep 26, 2023): @medpower > import {sas} from '@codemirror/lang-sas'; > import {r} from '@codemirror/lang-r'; I'm not sure those packages exist at all, were you loading via these before? Where version of BookStack were you on before? Was this working before? If you're loading via a legacy mode, via the `legacyMode` function, then your language will need to be exported in this file: https://github.com/BookStackApp/BookStack/blob/fa6fcc1c1c9dd2888bacee084d31c2f482c53e10/resources/js/code/legacy-modes.mjs
Author
Owner

@medpower commented on GitHub (Sep 26, 2023):

I just used codemirror library in other application and these two languages syntax were included in the library, please refer to the link https://codemirror.net/5/mode/index.html. I tried to export both in the legacy mode function but was not so lucky. Not sure if these models have been included into the package by default or we need to load them manually?

export {python} from '@codemirror/legacy-modes/mode/python';
export {sas} from '@codemirror/legacy-modes/mode/sas';
export {r} from '@codemirror/legacy-modes/mode/r';

Regards,
Stanley

@medpower commented on GitHub (Sep 26, 2023): I just used codemirror library in other application and these two languages syntax were included in the library, please refer to the link [https://codemirror.net/5/mode/index.html](url). I tried to export both in the legacy mode function but was not so lucky. Not sure if these models have been included into the package by default or we need to load them manually? ``` export {python} from '@codemirror/legacy-modes/mode/python'; export {sas} from '@codemirror/legacy-modes/mode/sas'; export {r} from '@codemirror/legacy-modes/mode/r'; ``` Regards, Stanley
Author
Owner

@ssddanbrown commented on GitHub (Sep 26, 2023):

@medpower

I tried to export both in the legacy mode function but was not so lucky.

What error did you see? Those imports/exports seem to exist.

@ssddanbrown commented on GitHub (Sep 26, 2023): @medpower > I tried to export both in the legacy mode function but was not so lucky. What error did you see? Those imports/exports seem to exist.
Author
Owner

@medpower commented on GitHub (Sep 27, 2023):

It seems what the changes were made under the resources folder will not be reflected in the dist directly, as I found from the frontend JS script and it still was the unchanged version. Could you please advise how to complie it accoridingly or just need to compress it with some general tool? Thanks

@medpower commented on GitHub (Sep 27, 2023): It seems what the changes were made under the resources folder will not be reflected in the dist directly, as I found from the frontend JS script and it still was the unchanged version. Could you please advise how to complie it accoridingly or just need to compress it with some general tool? Thanks
Author
Owner

@ssddanbrown commented on GitHub (Sep 27, 2023):

@medpower Details for building JS can be found in our dev-docs here.

@ssddanbrown commented on GitHub (Sep 27, 2023): @medpower Details for building JS can be found [in our dev-docs here](https://github.com/BookStackApp/BookStack/blob/development/dev/docs/development.md).
Author
Owner

@medpower commented on GitHub (Sep 29, 2023):

Thanks, it works now after replace with the built JS packages. :)

@medpower commented on GitHub (Sep 29, 2023): Thanks, it works now after replace with the built JS packages. :)
Author
Owner

@alexisfrjp commented on GitHub (Mar 29, 2025):

How can I add language support? (I just need a hint)
CodeMirror supports Verilog/SystemVerilog but my BookStack doesn't when using ```verilog

@alexisfrjp commented on GitHub (Mar 29, 2025): How can I add language support? (I just need a hint) CodeMirror supports `Verilog/SystemVerilog` but my BookStack doesn't when using ```verilog
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#3433