Elixir Syntax Highlighting on Stackoverflow

I looked into how the google-prettify works and prepared a plugin for elixir that seems to be working. Now I could use you guys’ help making sure it’s nice and robust.

Here’s how you can try it out: I put an editable example in the live-preview branch of my fork of the repo. Clone it and open it in a browser or go to rawgit and you can play around with the source code and see how the prettifier behaves.

Let me know what you think! Please point out what needs improving.

Notes:

  • The main things that can be broken is probably false positives on some classes. For example 1_000 is a correct integer, but 1__000 isn’t and shouldn’t be highlighted like one.
  • Things to be treated as “keywords” in Elixir are a bit of a judgement call, since most of the functionality is implemented with macros. I used my gut on this one - let me know if you think any constructs should (not) be treated as keywords but are(n’t).
  • Before I submit a PR to the main fork I’ll want to add some unit tests for the elixir prettifier - I just wanted to get some feedback first.
  • If you want to submit some changes to the prettifier in my fork, submit it to the lang-elixir branch - the live preview is just a utility and won’t be included in the PR for the main project.
  • I’m not sure what class the sigils should be highlighted as - they’re currently being coloured the same as atoms, because it’s consistent with the highlighting I have in my main editor.
  • I don’t think it’s worth it to support highlighting inside string interpolation - It would probably be more trouble than it’s worth using their createSimpleLexer
1 Like