Enhancement: Syntax highlight for more programming languages #1468
Replies: 5 comments 4 replies
-
Thanks for bringing this to my attention. Unfortunately, having more languages can seriously affect performance. Though I did learn how to correctly configure this in the process in case you would like to customize this. The following all done in You need to import the language you want if not already highlighted, should already be installed. I believe default is using "common" languages according to rehype-highlight docs, and they still seem to be included even when adding more languages like I did below. Note: highlight.js should already be installed import scala from 'highlight.js/lib/languages/scala';
// then change this relevant part as follows
const rehypePlugins: PluggableList = [
[rehypeKatex, { output: 'mathml' }],
[
rehypeHighlight,
{
detect: true,
ignoreMissing: true,
languages: { scala },
subset: langSubset,
},
],
[rehypeRaw],
];
I would still include it since it's a real option according to the docs: const langSubset = [
'python',
// omitted
'scala',
]; And in case you want to ignore some of the "common" languages, this works for me rehype-highlight docs: https://github.com/rehypejs/rehype-highlight#options rehypeHighlight,
{
detect: true,
ignoreMissing: true,
languages: { scala },
plainText: ['python'], // no longer highlights python
subset: langSubset,
}, |
Beta Was this translation helpful? Give feedback.
-
Thank you for your timely response. Unfortunately, after added the code as you suggested, the web UI has malfunctioned and no longer displays the login fields. The "欢迎" here means "welcome" in my language. It is worth mentioning that I am using the native version without a docker container. I tried Even after I removed those code edits, the problem persisted. I wonder if I can reclone and rebuild the repository without data loss. |
Beta Was this translation helpful? Give feedback.
-
I'm so sorry for the false alarm! It turns out the UI issue was entirely my fault due to accidentally turning off email login. I feel terrible for wasting your time, but I'm grateful for your patience and the helpful code provided by @danny-avila. Syntax highlighting is now working perfectly. I've learned a valuable lesson about double-checking my settings before reporting issues! While I have your attention, I'd also like to respectfully inquire about the possibility of enhancing syntax highlighting customization. Would it be feasible to consider adding options or environment variables to enable users to more easily add support for additional languages, without requiring direct code modification? I understand adding this feature might require more experienced hands, but I'd be honored to learn some JavaScript (or TypeScript) and create a pull request. |
Beta Was this translation helpful? Give feedback.
-
Yes that could be a good feature. For now I'm prioritizing some things already on the roadmap, such as a config yaml file, which may in turn help this cause |
Beta Was this translation helpful? Give feedback.
-
How bad is syntax highlighting performance hit? Although it's not a good test, because these specific competitors have overall snappier and more responsive feeling UI Maybe there should be a guide in the docs on how to add highlighting to more languages. |
Beta Was this translation helpful? Give feedback.
-
What features would you like to see added?
Make syntax highlighting customizable for a wider range of programming languages.
More details
I have deployed LibreChat on my server and it has transformed my GPT and Gemini experience! The UI is sleek, the UX seamless, and the documentation has been a lifesaver. But as someone who works extensively with some less popular languages like Scala and Verilog, I've hit a snag—these languages aren't currently supported for syntax highlighting, despite being supported by
highlight.js
.While this intentional behavior aligns with ChatGPT, it restricts customizability within LibreChat as a deployable web application. Integrating configurable highlighting, even through code edits, would be a huge advantage over the default ChatGPT UI.
Additional infomation:
langSubset
constant inclient/src/utils/languages.ts
, but the changes didn't produce the expected highlighting behavior.Which components are impacted by your request?
UI
Pictures
Bard:
ChatGPT:
LibreChat:
Code of Conduct
Beta Was this translation helpful? Give feedback.
All reactions