Unleash awesomeness. Private packages, team management tools, and powerful integrations. Get started with npm Orgs »

eshighlight-harmony

0.4.0 • Public • Published

eshighlight Build Status

JavaScript code highlighter based on esprima.

Install

npm install eshighlight

Usage

Takes a JavaScript string, returns an html string.

var highlight = require('eshighlight');
 
highlight('var x = 42');

which returns:

<span class="keyword">var</span> <span class="identifier">x</span> = <span class="numeric">42</span>

Prior Art

Before writing this, I looked at these solutions:

The main motivation for this library was so I can make my blog to look like sublime. None of the highlighters I looked at let you color parameters. I want that nice orange on my params yo.

I didn't like that they all only tokenized rather than doing a proper parse. I think the parse tree approach might be interesting.

Compared to highlight.js and google-code-prettify, eshighlight has the drawbacks that it does not support languages besides JavaScript and only works in node.

License

MIT

install

npm i eshighlight-harmony

Downloadsweekly downloads

5

version

0.4.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability