Labs/Bespin/SyntaxHighlighting
Bespin is built to have multiple syntax highlighting engines so people can experiment. We already have two syntax engines:
- simple: This is the default engine that was built from scratch to be very fast for our implementation. Although fast, it is very simple and basic (doesn't grok variables and such)
- codemirror: Roberto Saccon ported the codemirror engine over. It is smarter and can give you error checking and AST based work. It uses the Malte Ubl work to do things in a Web Worker
More details below:
Simple
The simple system lives in frontend/js/bespin/syntax/simple (e.g. here).
Each language lives within there as languagename.js.
To get started you can choose a language that is similar to the one you want to support. For example, if it is a C style language, maybe you go for javascript.js
At the end make sure that you register your system with the various types that you may want to use:
bespin.syntax.simple.Resolver.register(new bespin.syntax.simple.JavaScript(), ['js', 'javascript', 'ecmascript', 'jsm', 'java']);
You will want to use names that people will use as names in "set language javascript" and as suffixes on filenames so the automated system can pick them up (e.g. "js").
The core code in the simple system is a trivial state machine that processes a line on its own merits, and just holds a flag to note whether the system is in a multi-line comment, and that is that!
Codemirror
The codemirror system lives in the codemirror directory and has its own thing going on.
Great stuff, and much more detail and color.
Contributing
If you implement a new file, please consider submitting it to us so we can put it in!