Highlight ECMAScript syntax for the console or any other medium.
npm install highlight-esHighlight ECMAScript syntax for the console or any other medium.
npm install highlight-es
`Usage
`js
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));
` ⬇
You can pass custom renderer to target other medium, e.g.:
`js
highlight(code, {
string: str => ...,
punctuator: str => ...,
keyword: str => ...,
number: str => ...,
regex: str => ...,
comment: str => ...,
invalid: str => ...
});
``