Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bobbylight/jshighlight
A simple syntax highlighting library for web applications
https://github.com/bobbylight/jshighlight
syntax-highlighting typescript
Last synced: about 1 month ago
JSON representation
A simple syntax highlighting library for web applications
- Host: GitHub
- URL: https://github.com/bobbylight/jshighlight
- Owner: bobbylight
- License: mit
- Created: 2017-06-21T03:23:51.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-03-14T19:57:24.000Z (over 1 year ago)
- Last Synced: 2024-04-25T04:45:16.387Z (7 months ago)
- Topics: syntax-highlighting, typescript
- Language: TypeScript
- Size: 1.23 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jsHighlight - Simple syntax highlighting for webapps
![Build](https://github.com/bobbylight/jshighlight/actions/workflows/build.yml/badge.svg)
![CodeQL](https://github.com/bobbylight/jshighlight/actions/workflows/codeql-analysis.yml/badge.svg)
[![codecov](https://codecov.io/gh/bobbylight/jshighlight/branch/master/graph/badge.svg?token=1AzwBREy4R)](https://codecov.io/gh/bobbylight/jshighlight)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
```sh
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:
```sh
npm test # Tests only
npm run coverage # Generates coverage report
```The generated coverage report lives here:
```sh
open coverage/index.html
```## Consuming the library in a TypeScript application
```typescript
import highlighter from 'jshighlight/lib/highlighter';
import JsonParser from 'jshighlight/lib/parsers/json-parser';...
const html: string = highlighter.highlight(new JsonParser(), jsonStr);
```