12 Jul 2009

Erlang syntax highlighting

NOTE: This is an old post and this site no longer uses SHJS to highlight code blocks.

For this site I wanted to use a simple syntax highlighter written in Javascript. Unfortunately, when I searched, none of the existing libraries seemed to support Erlang source code. So I descended like a vulture onto the vim syntax file and somehow mashed it into something that resembles a GNU Source-highlight language definition.


start() ->
    io:fwrite("Hello, world!").

This can then be converted for use with SHJS, which is the library I'm using to highlight the source code above. The .lang file should also work with GNU Source-highlight and any other software using the same format, but I've not tested it.


I've included the converted sh_erlang.js file for use with SHJS, as well as the original erlang.lang file (which depends on number.lang).


This is now used on erldocs.com, which is a cool, easy to search version of the erlang.org docs, nice one @daleharvey :)