# gulp-highlight-code

> Pipe code snippets through highlight.js using gulp to pre-tag code blocks at compile time.

Latest version **1.0.8** (published 2017-12-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install gulp-highlight-code
pnpm add gulp-highlight-code
yarn add gulp-highlight-code
bun add gulp-highlight-code
```

## 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 | 1.0.8 |
| Published | 2017-12-31 |
| First published | 2017-12-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Jason Manson-Hing |
| Maintainers | ifalluphill |
| Keywords | gulp, highlight.js, highlight, syntax |

## Links

- npm: https://www.npmjs.com/package/gulp-highlight-code
- Repository: https://github.com/iFallUpHill/gulp-highlight-code
- Homepage: https://github.com/iFallUpHill/gulp-highlight-code#readme
- Issues: https://github.com/iFallUpHill/gulp-highlight-code/issues
- npm.io page: https://npm.io/package/gulp-highlight-code

## Dependencies (4)

- [cheerio](https://npm.io/package/cheerio.md) ^1.0.0-rc.2
- [through2](https://npm.io/package/through2.md) ^2.0.3
- [highlight.js](https://npm.io/package/highlight.js.md) ^9.12.0
- [plugin-error](https://npm.io/package/plugin-error.md) ^0.1.2

## 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) — 2017-12-31
- 1.0.7 — 2017-12-31
- 1.0.6 — 2017-12-31
- 1.0.5 — 2017-12-31
- 1.0.4 — 2017-12-31
- 1.0.3 — 2017-12-30
- 1.0.2 — 2017-12-30
- 1.0.1 — 2017-12-30
- 1.0.0 — 2017-12-30

## README

# gulp-highlight-code

[![npm](https://img.shields.io/npm/v/gulp-highlight-code.svg)]()
[![npm](https://img.shields.io/npm/l/gulp-highlight-code.svg)]()

[Check it out on npm!](https://www.npmjs.com/package/gulp-highlight-code "gulp-highlight-code")

## About
Pipe code snippets through [highlight.js](https://highlightjs.org/ "highlight.js")  using `gulp` to pre-tag code blocks at compile time. This only applies to codeblocks formatted properly using both the `pre` and a `code` tags (i.e. `<pre><code>`).

`gulp-highlight-code` will try to automatically detect a codeblock's language. To improve the accuracy of gulp-highlight-code, add the `data-lang` HTML attribute to the `code` tag containing code block to specify the language.

## Install

```bash
npm install gulp-highlight-code --save-dev
```

## Usage

### gulpfile.js
```js
var gulp = require('gulp');
var highlight = require('gulp-highlight-code');

gulp.task('default', function () {
	gulp.src('src/index.html')
		.pipe(highlight())
		.pipe(gulp.dest('dist'));
});
```

### src/index.html

```html
<!-- Will be highlighted -->
<pre><code data-lang="html">&lt;div&gt;
	Highlighted
&lt;div&gt;</code></pre>

<!-- Will not be highlighted -->
<pre><code data-lang="html" class="no-highlight">&lt;div&gt;
	Not Highlighted
&lt;div&gt;</code></pre>

```

#### Notes

* You must use escaped HTML within the `<pre><code>` block.

* Code blocks that have been highlighted using highlight.js will have the `hljs` class added to them. Similarly, code blocks that were not highlighted will have the `no-hljs` class added to them.

## Known Issues

* No CSS is included. This is intentional as this library is only intended to pre-wrap code snippets within code blocks using highlight.js tags. You are required to define and include your own CSS.

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