Socket
Book a DemoInstallSign in
Socket

codemirror-highlight

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

codemirror-highlight

Generating HTML containing highlighted code with CodeMirror

1.1.1
latest
Source
npmnpm
Version published
Weekly downloads
20
400%
Maintainers
1
Weekly downloads
 
Created
Source

codemirror-highlight

Generating HTML containing highlighted code with CodeMirror

Installation

npm install codemirror-highlight

Example

var assert = require('assert');
var CodeMirror = require('codemirror-highlight');

CodeMirror.loadMode('javascript');
var html = CodeMirror.highlight('1', { mode: 'javascript' });

assert.equal(html, '<span class="cm-number">1</span>');

API

CodeMirror.loadMode(mode)

  • mode - a string containing the mode name

Load mode shipped with CodeMirror. A list of modes can be found here.

CodeMirror.highlight(code, options)

  • code - a string of code to be highlighted
  • options - an object literal supporting these options:
    • mode - the same as the mode option you should pass to vanilla CodeMirror
    • tabSize - the width of a tab character. Defaults to 4.

Return the HTML containing highlighted code

Keywords

highlight

FAQs

Package last updated on 31 Oct 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.