jshighlight

A simple syntax highlighting library for web applications

MIT License

Downloads
9
Stars
1

jsHighlight - Simple syntax highlighting for webapps

I built this after highlight.js being too heavy, and requiring a custom build to remove unneeded parsers, and other highlighting packages having similar issues.

Install

git clone [email protected]/github.com/bobbylight/jshighlight.git
cd jshighlight
npm install
npm run build   # Compiles source and builds the library into lib/
npm run dev     # Runs a demo app and watches for changes

The demo application will be hosted at file://path/to/jshilight/demo/index.html.

To run tests:

npm test         # Tests only
npm run coverage # Generates coverage report

The generated coverage report lives here:

open coverage/index.html

Consuming the library in a TypeScript application

import highlighter from 'jshighlight/lib/highlighter';
import JsonParser from 'jshighlight/lib/parsers/json-parser';

...

const html: string = highlighter.highlight(new JsonParser(), jsonStr);