highlight-codemirror
A syntax highlighter built to run in node and consume CodeMirror modes.
API
highlight(source, mode)
The source should be a string of code to highlight. The mode should be either the name of a mode (as a string) or an object (allowing you to specify other options).
var highlight = ; var html = ;// => '<span class="cm-variable">assert</span>(<span class="cm-keyword">typeof</span> <span class="cm-string">"foo"</span> <span class="cm-operator">===</span> <span class="cm-string">"string"</span>)'
highlight.loadMode(name);
Loading modes is synchronous, so you may wish to pre-populate the cache bu loading the mode up front. You can also load custom modes by passing an absolute path to a JavaScript file. e.g. the null mode might look like:
/custom-null-mode.js
var CodeMirror = ; // Minimal default mode.CodeMirror;
You could then do:
highlight;;
License
MIT