isagalaev/highlight.js — pull request #608 by polazarus (2014-10-18 23:08:18+00:00)
Title: Fix OCaml language support

The major concern with the state of OCaml in Highlight.js is about the apostrophe `'`. They are very used in OCaml : they are allowed in identifiers (`my_var'`), and are used to prefix "generic" types (type variable, e.g. in `'a list` type of a generic list). Yet the existing language description, totally ignore it (except for character literals) and as a result the first use of `'` messes up the highlighting of the rest of the code (in particular interfaces).

The proposed modification provides various improvements:

- character support (as char rather than string)
- type variable (`'a`)
- polymorphic variant tag (``[ `A | `B ]``)
- module name/variant constructor (module `List` or constructor `Some a`)
- support `'` in identifier
- add support for literals `()` `[]` `[||]`
- better support for numbers (OCaml ≠ C)
- remove unrelated rules (from F# maybe?)
- add new keywords (`method!`, `open!` etc.)
- cleanup built-in types
- add some tests

A step backward: remove very incomplete type definition. It would not have been easy to really support that and in terms of highlighting I don't think it's worth it.

The complete test suite sucessfully run including the language detection.

Cheers, M