npm.io
1.0.2 • Published 11 years ago

codemirror-highlight-node

Licence
MIT
Version
1.0.2
Deps
3
Vulns
0
Weekly
0
Stars
1

Build Status Dependency Status

codemirror-highlight-node

Transforms source code into formatted HTML using CodeMirror. Tabs, whitespaces and new line characters are preserved from original source code.

Install

npm install codemirror-highlight-node

Usage

var highlight = require('codemirror-highlight-node');
highlight('function Test() {}', 'javascript');
// => <span class="cm-keyword">function</span> <span class="cm-variable">Test</span>() {}

API

Loading this module will add two functions to CodeMirror:

  • loadMode(name) - resolve and load requested mode
  • highlightCode(code, modeSpec) - transform soruce code to formatted HTML

As modeSpec parameter you can use name (e.g. "javascript"), alias (e.g. "csharp" for C#) or full modeSpec object required by CodeMirror. Module exports directly highlightCode function. CodeMirror object is also re-exported as highlightCode.CodeMirror.

LICENSE

MIT

Keywords