Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Add Syntax Highlighting to Sidebar Code Snippets #77

Merged
merged 2 commits into from
Oct 17, 2024

Conversation

SOUMITRO-SAHA
Copy link
Contributor

Resolve Code Highlighting Issue in Sidebar

Issue Reference: #76


Description:

This PR resolves issue #76 where code snippets in the sidebar were not displaying syntax highlighting. The issue has been addressed, ensuring that code blocks in the sidebar are now properly highlighted, improving readability.

How to Test:

  • Open a sidebar that includes code snippets.
  • Verify that the code is highlighted according to the selected programming language.

image

@mathewpareles
Copy link
Contributor

This is great, but it seems like you're using an external react-syntax-highlighter library to do this.

Can you instead make it use the Monaco editor (which is what VS Code uses to render code)?

Or even better, use VS Code's native code renderer, instead of a library.

@andrewpareles
Copy link
Contributor

I think we're going to have to use Monaco to do this instead of react-syntax-highlighter.

@SOUMITRO-SAHA
Copy link
Contributor Author

Hi, @andrewpareles @mathewpareles

I have a quick question regarding Monaco. Is there a way to utilize VS Code’s Monaco syntax highlighting without installing additional packages? I've tried implementing this feature with highlight.js and prism.js, but they didn't work perfectly.

Additionally, for Monaco, do I need to install the monaco-editor separately and resolve the .ttf font loading using tools like url-loader? This approach seems cumbersome, and I'm not entirely satisfied with it either.

I've explored multiple options before submitting the last PR. Then, I reverted back to using react-syntax-highlighter, but I'm not keen on relying on external libraries.

It would be great if you could suggest a better approach or provide some resources for implementing this feature more efficiently.

@andrewpareles
Copy link
Contributor

andrewpareles commented Oct 11, 2024

Thanks for all the work. It's possible to add syntax highlighting in a Monaco editor - you just need to build a custom Monarch language syntax definition. I've done this in the past and will finish up this PR in a bit! (Edit: the custom Monarch definition might not be needed...)

@andrewpareles andrewpareles added roadmap-under consideration New feature or request high priority High priority issue and removed roadmap-under consideration New feature or request labels Oct 15, 2024
@IDLe-Engineering
Copy link
Contributor

well, this is better than nothing ;-) as long as the monaco implementation isn't done, I would consider using it in the main branch. I have adapted the implementation to the latest architecture and it's working like a charm...If anyone is interested, I will create a new pull request to be compatible to the latest main

@andrewpareles andrewpareles merged commit 6dfab6d into voideditor:main Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
high priority High priority issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants