earl-grey icon indicating copy to clipboard operation
earl-grey copied to clipboard

Syntax Highlighting

Open davej opened this issue 9 years ago • 5 comments

Is there any syntax highlighting definitions available? Or is there a language that earl grey shares similar syntax with, so I can piggy-back on the syntax highlighting defined for that language?

davej avatar May 09 '15 19:05 davej

I made an earl-mode for emacs here. I also have a CodeMirror module here which is currently embedded in repple, the engine behind this page (I'll try to find the time to make a pull request to include it in CodeMirror, but I'd probably need to rewrite it in JS to get it accepted). Then I also have a mode for highlight.js here. So, yeah, there are some definitions around, but it's kind of messy and scattered.

EG is a bit tricky to highlight as well since it's not keyword-based: alice bob: charlie should highlight alice as a keyword, for example, because of its positioning.

I believe Python might work okay as an alternative mode since most control structures have the same syntax.

breuleux avatar May 09 '15 19:05 breuleux

Thanks, did a bit of trial and error and python works ok but I found CoffeeScript works best. I quickly added dot-strings and ;; comments so it works quite well now.

davej avatar May 09 '15 22:05 davej

Yeah, now that I think of it, CoffeeScript would work well too. What editor are you using? If you do end up tweaking a decent mode for EG, put it up somewhere and I'll link to it when I end up adding a section on editor support.

breuleux avatar May 09 '15 22:05 breuleux

Will do. Using Atom. Highlighting goes a bit horrible when using dash-er-ized variable names but I'll post it here if I get it working well.

davej avatar May 09 '15 23:05 davej

For those who are interested, I have written a guide on syntax highlighting for Earl Grey:

http://breuleux.github.io/earl-grey/contrib.html

Also, someone is developing an Atom mode here: https://github.com/MadcapJake/language-earl-grey. Probably best not to make more than one :)

breuleux avatar May 12 '15 06:05 breuleux