codemirror-highlight-node

1.0.2 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i codemirror-highlight-node

Weekly Downloads

4

Version

1.0.2

License

MIT

Last publish

Collaborators

  • dorny