# highlights

> Syntax highlighter

Latest version **3.1.6** (published 2021-06-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install highlights
pnpm add highlights
yarn add highlights
bun add highlights
```

Provides the command `highlights`.

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.1.6 |
| Published | 2021-06-08 |
| First published | 2014-03-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 818.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 524 |
| Maintainers | benogle, nathansobo, kevinsawicki, maxbrunsfeld, zcbenz, soldair, bcoe, as-cii, atom-team, jasonrudolph |

## Links

- npm: https://www.npmjs.com/package/highlights
- Repository: https://github.com/atom/highlights
- Issues: https://github.com/atom/highlights/issues
- npm.io page: https://npm.io/package/highlights

## Dependencies (7)

- [once](https://npm.io/package/once.md) ^1.3.2
- [yargs](https://npm.io/package/yargs.md) ^17.0.1
- [season](https://npm.io/package/season.md) ^6.0.2
- [fs-plus](https://npm.io/package/fs-plus.md) ^3.0.0
- [first-mate](https://npm.io/package/first-mate.md) ^7.0.2
- [underscore-plus](https://npm.io/package/underscore-plus.md) ^1.5.1
- [first-mate-select-grammar](https://npm.io/package/first-mate-select-grammar.md) ^1.0.3

## Recent versions

- 3.1.6 (latest) — 2021-06-08
- 3.2.0-candidate.1 (fs-downgrade) — 2017-08-09
- 3.1.0 (next) — 2017-07-11
- 3.1.4 — 2019-06-27
- 3.1.2 — 2019-06-25
- 3.1.2-0 — 2019-06-25
- 3.1.1 — 2017-10-23
- 3.2.0-candidate.0 — 2017-08-08
- 3.0.1 — 2017-03-06
- 2.1.3 — 2017-03-03
- 2.1.1 — 2017-01-25
- 2.0.1 — 2017-01-20
- 1.4.1 — 2016-08-16
- 1.4.1-candidate — 2016-08-12
- 1.4.0 — 2016-07-13
- … 22 more at https://npm.io/package/highlights/versions

## README

![](https://f.cloud.github.com/assets/671378/2454103/24d89962-aee6-11e3-9dcf-ee2d81ec0373.jpg)

Reads in code, writes out HTML with CSS classes based on the tokens in the code.

[![Build Status](https://travis-ci.org/atom/highlights.svg?branch=master)](https://travis-ci.org/atom/highlights)

See it in action [here](https://atom.github.io/highlights/examples).

### Installing

```sh
npm install highlights
```

### Using

Run `highlights -h` for full details about the supported options.

To convert a source file to tokenized HTML run the following:

```sh
highlights file.coffee -o file.html
```

Now you have a `file.html` file that has a big `<pre>` tag with a `<div>` for
each line with `<span>` elements for each token.

Then you can compile an existing Atom theme into a stylesheet with the
following:

```sh
git clone https://github.com/atom/atom-dark-syntax
cd atom-dark-syntax
npm install -g less
lessc --include-path=styles index.less atom-dark-syntax.css
```

Now you have an `atom-dark-syntax.css` stylesheet that be combined with
the `file.html` file to generate some nice looking code.

Check out the [examples](https://atom.github.io/highlights/examples) to see
it in action.

Check out [atom.io](https://atom.io/packages) to find more themes.

Some popular themes:
  * [atom-dark-syntax](https://github.com/atom/atom-dark-syntax)
  * [atom-light-syntax](https://github.com/atom/atom-light-syntax)
  * [solarized-dark-syntax](https://github.com/atom/solarized-dark-syntax)
  * [solarized-light-syntax](https://github.com/atom/solarized-light-syntax)

#### Using in code

```coffee
Highlights = require 'highlights'
highlighter = new Highlights()
html = highlighter.highlightSync
  fileContents: 'var hello = "world";'
  scopeName: 'source.js'

console.log html
```

Outputs:

```html
<pre class="editor editor-colors">
  <div class="line">
    <span class="source js">
      <span class="storage modifier js"><span>var</span></span>
      <span>&nbsp;hello&nbsp;</span>
      <span class="keyword operator js"><span>=</span></span>
      <span>&nbsp;</span>
      <span class="string quoted double js">
        <span class="punctuation definition string begin js"><span>&quot;</span></span>
        <span>world</span>
        <span class="punctuation definition string end js"><span>&quot;</span></span>
      </span>
      <span class="punctuation terminator statement js"><span>;</span></span>
    </span>
  </div>
</pre>
```

### Loading Grammars From Modules

highlights exposes the method `requireGrammarsSync`, for loading grammars from
npm modules. The usage is as follows:

```bash
npm install atom-language-clojure
```

```coffee
Highlights = require 'highlights'
highlighter = new Highlights()
highlighter.requireGrammarsSync
  modulePath: require.resolve('atom-language-clojure/package.json')
```

### Developing

* Clone this repository `git clone https://github.com/atom/highlights`
* Update the submodules by running `git submodule update --init --recursive`
* Run `npm install` to install the dependencies, compile the CoffeeScript, and
  build the grammars
* Run `npm test` to run the specs

:green_heart: Pull requests are greatly appreciated and welcomed.

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