highlight-es

1.0.3 • Public • Published

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)

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.3
    556,585
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.3
    556,585
  • 1.0.1
    381
  • 1.0.0
    84

Package Sidebar

Install

npm i highlight-es

Weekly Downloads

557,050

Version

1.0.3

License

MIT

Unpacked Size

4.34 kB

Total Files

4

Last publish

Collaborators

  • inikulin