# makestatic-highlight

> Syntax highlight code blocks

Latest version **1.0.2** (published 2018-01-18) · MIT license · 0 weekly downloads

## Install

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

## 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.2 |
| Published | 2018-01-18 |
| First published | 2017-03-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | muji |
| Maintainers | tmpfs |
| Keywords | makestatic-plugin, syntax, highlight, code |

## Links

- npm: https://www.npmjs.com/package/makestatic-highlight
- Repository: https://github.com/makestatic/compiler
- Homepage: https://makestatic.ws
- Issues: https://github.com/makestatic/compiler/issues
- npm.io page: https://npm.io/package/makestatic-highlight

## Dependencies (1)

- [highlightjs](https://npm.io/package/highlightjs.md) ^9.10.0

## 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.2 (latest) — 2018-01-18
- 1.0.1 — 2018-01-17
- 1.0.0 — 2017-03-16

## README

# Highlight

> Syntax highlight code blocks

Make your code pretty using [highlightjs](https://highlightjs.org/ "Highlight.js").

---

- [Install](#install)
- [API](#api)
  - [Highlight](#highlight)
    - [See Also](#see-also)
    - [Highlight](#highlight-1)
      - [Options](#options)
    - [.getLanguage](#getlanguage)
    - [.highlight](#highlight-2)
    - [.sources](#sources)
- [License](#license)

---

## Install

```
yarn add makestatic-highlight
```

## API

### Highlight

For each HTML file with an AST syntax highlight code blocks that have a
class name indicating the source code language.

#### See Also

* [Highlight.js](https://highlightjs.org/ "Highlight.js")
* [Highlight.js API](http://highlightjs.readthedocs.io/en/latest/api.html "Highlight.js API")

#### Highlight

```javascript
new Highlight(context, options)
```

Create a Highlight plugin.

The default `selector` when none is given is `code[class]`.

The options specific to `highlight.js` are equivalent to the default
values except that `classPrefix` is set to the empty string so class names
will not contain the `hljs-` prefix.

* `context` Object the processing context.
* `options` Object plugin options.

##### Options

* `selector` String query for code blocks.
* `language` Function extract language from class names.
* `highlighter` Function override the default highlighter.
* `classPrefix` String highlight.js `classPrefix` option.
* `tabReplace` String highlight.js `tabReplace` option.
* `useBR` Boolean highlight.js `useBR` option.
* `languages` Array highlight.js `languages` option.

#### .getLanguage

```javascript
Highlight.prototype.getLanguage(file, element)
```

Default implementation to extract a language identifier for an element.

Use the `language` option to supply an alternative implementation.

Finds the first `lang-` or `language-` class name on the element and
returns the language identifier.

Returns string language identifier.

* `file` Object the current file.
* `element` Object the matched element.

#### .highlight

```javascript
Highlight.prototype.highlight(file, element, lang, text)
```

Default implementation to highlight code blocks.

Use the `highlighter` option to supply an alternative implementation.

Returns string highlighted code.

* `file` Object the current file.
* `element` Object the matched element.
* `lang` String the language identifier.
* `text` String content of the code block.

#### .sources

```javascript
Highlight.prototype.sources(file, context, options)
```

For each file with an HTML AST find elements that match the `selector`
option. Call the `language` function for each matched element and if a
language string is returned call the `highlighter` function.

Use the return value from the `highlighter` function as a DOM document
fragment and update the code block with the new child nodes.

* `file` File the current file.
* `context` Object the processing context.
* `options` Object plugin options.

## License

MIT

---

Created by [mkdoc](https://github.com/mkdoc/mkdoc) on March 16, 2017

[docs]: https://makestatic.ws/docs/ "Documentation"
[standalone manual]: https://github.com/makestatic/website/blob/master/MANUAL.md "Standalone Manual"
[yarn]: https://yarnpkg.com "Yarn"
[webpack]: https://webpack.js.org "Webpack"
[babel]: https://babeljs.io "Babel"
[postcss]: http://postcss.org "Postcss"
[sugarss]: https://github.com/postcss/sugarss "Sugarss"
[reshape]: https://github.com/reshape/reshape "Reshape Source Code"
[reshapeml]: https://reshape.ml "Reshape"
[clean-css]: https://github.com/jakubpawlowicz/clean-css "Clean CSS"
[html-minifier]: https://github.com/kangax/html-minifier "Html Minifier"
[uglify-js]: https://github.com/mishoo/UglifyJS2 "Uglify JS"
[imagemin]: https://github.com/imagemin/imagemin "Imagemin"
[mkdoc]: https://github.com/mkdoc/mkdoc "Mkdoc"
[browsersync]: https://www.browsersync.io "Browsersync"
[yeoman]: http://yeoman.io "Yeoman"
[spike]: https://www.spike.cf "Spike"
[validator]: https://github.com/validator/validator "HTML Validator"
[github pages]: https://pages.github.com "Github Pages"
[amazon s3]: https://aws.amazon.com/s3/ "Amazon S3"
[google sitemaps]: https://support.google.com/webmasters/answer/183668?hl=en&ref_topic=4581190 "Google Sitemaps"
[sitemaps]: https://www.sitemaps.org/ "Sitemaps"

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