# node-highlight

> A fork of highlight.js, lighter and a bit faster

Latest version **1.0.8** (published 2022-03-29) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install node-highlight
pnpm add node-highlight
yarn add node-highlight
bun add node-highlight
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.8 |
| Published | 2022-03-29 |
| First published | 2022-03-24 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 120.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Devil64-Dev |
| Maintainers | devil64-dev |
| Keywords | syntax, highlight, node-highlight |

## Links

- npm: https://www.npmjs.com/package/node-highlight
- Repository: https://github.com/Devil64-Dev/node-highlight
- Homepage: https://github.com/Devil64-Dev/node-highlight/#readme
- Issues: https://github.com/Devil64-Dev/node-highlight/issues
- npm.io page: https://npm.io/package/node-highlight

## Alternatives

- [@oh-my-pi/pi-natives](https://npm.io/package/@oh-my-pi/pi-natives.md) — 51.8K weekly downloads
- [@capgo/capacitor-light-sensor](https://npm.io/package/@capgo/capacitor-light-sensor.md) — 3.0K weekly downloads
- [@heyhuynhgiabuu/pi-diff](https://npm.io/package/@heyhuynhgiabuu/pi-diff.md) — 492 weekly downloads
- [@lotsa/verdant-lang-asm](https://npm.io/package/@lotsa/verdant-lang-asm.md) — 38 weekly downloads
- [new-era-syntax](https://npm.io/package/new-era-syntax.md) — 20 weekly downloads

## Recent versions

- 1.0.8 (latest) — 2022-03-29
- 1.0.7 — 2022-03-28
- 1.0.6 — 2022-03-28
- 1.0.5 — 2022-03-24

## README

# node-highlight

A fork of [highlight.js](https://github.com/highlightjs/highlight.js), lighter and a bit faster.

**IMPORTANT**:
Support for highlight html DOM was remove. This is mean to be used as a faster solution to highlight code passed as string.

This fork was rewritten in TypeScript, if you are writing a new language you
can get help using types.

## Usage

The usage is the same as the core `highlight` function.

```javascript
  import { highlighter } from 'node-highlight';

  console.info(highlighter.highlight('code', 'lang', true));

  // See `Result` type for more information.
```

The package has support for ESM and CommonJS modules.

If you want a highlighter with custom options you can import the
main class called `NodeHighlight` and create a new instance.

```javascript
  import { NodeHighlight } from 'node-highlight';
  const nhl = new NodeHighlight({ classPrefix: 'custom-' });
```

**!NOTE**: The result is just a HTML string if you are using vanilla javascript you can inner to an element. Otherwise if you are using a framework like React you can use a parser.
For get help writing a new parser see [node-highlight-react](https://github.com/Devil64-Dev/node-highlight-react.git) parser.

## Core languages

The supported languages for now are:

- css

- javascript

- json

- perl

- python

- scss

- typescript

- xml | html | svg | xhtml | atom | plist | xsl | rss

Register custom languages isn't available for now. But I'm working on it.

## Styles

You can use styles from [highlight.js](https://github.com/highlightjs/highlight.js),
or create your owns. You can see the source of the target language definition to
get help developing your own styles.

---
_Source: https://npm.io/package/node-highlight · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
