highlight-es
Highlight ECMAScript syntax for the console or any other medium.
Last updated 9 years ago by inikulin .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install highlight-es 
SYNC missed versions from official npm registry.

highlight-es

Build Status

Highlight ECMAScript syntax for the console or any other medium.

Install

npm install highlight-es

Usage

const highlight = require('highlight-es');

function testFunc () {
    const re    = /(.+) awesome$/;
    const match = 'You are awesome'.match(re);

    return match[1];
}

const code = testFunc.toString();

console.log('\n' + highlight(code));

example

You can pass custom renderer to target other medium, e.g.:

highlight(code, {
    string:     str => ...,
    punctuator: str => ...,
    keyword:    str => ...,
    number:     str => ...,
    regex:      str => ...,
    comment:    str => ...,
    invalid:    str => ...
});

Related

is-es2016-keyword - Determine if string is an ES2016 keyword.

Author

Ivan Nikulin (ifaaan@gmail.com)

Current Tags

  • 1.0.3                                ...           latest (7 years ago)

3 Versions

  • 1.0.3                                ...           7 years ago
  • 1.0.1                                ...           8 years ago
  • 1.0.0                                ...           9 years ago
Maintainers (1)
Downloads
Total 2
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (3)
Dev Dependencies (2)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE