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

Support for syntax highlighting in the web application #165

Open
cardillan opened this issue Oct 18, 2024 · 2 comments
Open

Support for syntax highlighting in the web application #165

cardillan opened this issue Oct 18, 2024 · 2 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@cardillan
Copy link
Owner

This is probably a fairly complicated task, but an immensely useful one.

A tool for the syntax highlighting must be chosen. Mindcode grammar is primarily defined in ANTLR4 format, so a tool that would be capable of using this format directly would be strongly preferred. If that's not possible, we'll create a separate definition for the syntax highlighting in any other format that would be needed.

@cardillan cardillan added enhancement New feature or request help wanted Extra attention is needed labels Oct 18, 2024
@JeanJPNM
Copy link

JeanJPNM commented Jan 7, 2025

I believe the easiest way of doing this is by using a code editor library, which enables syntax highlighting as well as other features like autocompletion.

The three libraries that I found adequate for this are:

  • CodeMirror. I have been experimenting with this one to make a playground for mlogls
  • Monaco Editor. This is the one mlogjs uses for its editor
  • Ace Editor. I am only aware that this one exists, never used it though

Out of all of them I would recommend CodeMirror, since it has very good mobile support (Monaco doesn't) and is very lightweight as well.

According to the documentation the preferred way to do syntax highlighting is by writing a lezer grammar since those support incremental parsing, but this article also contains a demonstration on how to integrate antlr grammar with codemirror.

@cardillan
Copy link
Owner Author

Thank you a lot! At a quick glance, CodeMirror looks promising. I think the ANTLR grammar could be rewritten in the lezer grammar, although it will be some work. I'll try it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants