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

ACE Editor Syntax Highlighting Support #14

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

agduncan94
Copy link

I have added syntax highlighting support for ACE Editor for use with Dockstore.org and thought it might be useful for someone else in the future.

The process to reproduce isn't completely automated, however it is pretty straightforward. I steps are outlined in the README.

Let me know if you want anything changed such as filename conventions, more documentation, etc.

@cjllanwarne
Copy link
Contributor

This is fantastic, thanks for the contribution!

My only comment would be whether it is possible to have "installation instructions" for users of Ace editor too? If it's just an import then presumably it's just something along the lines of "you should be able to use the JavaScript file as is"? Or is it more complicated than that?

@agduncan94
Copy link
Author

agduncan94 commented Jun 25, 2018

Unfortunately even on the Ace editor website they don't really have good docs for using custom syntax highlighters. It was a bit of trial and error on my part. Assuming you have ace setup, you have to import the custom highlighter in such a way that Ace can find it properly. This involved changing the ace.define(...) line found in ace/wdl_highlight_rules.js (the first line of the file). Note that the rest of the file remains the same. While the change is pretty small, it could be a potential blocker, especially for someone who has never added a custom syntax highlighter to Ace editor. I could add a link to how we use it in our project. That way at least someone new to Ace could have a working example to look at.

Here is a link to how we use it: custom-grammars.js

Edit: Actually looking through the code in more detail, we do also have to define WDL as a language (they call it mode) to be able to call it in Ace. This is mostly boilerplate code, and can be found at line 290-308

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants