# node-highlight-react

> Syntax highlight for React.js using node-highlight

Latest version **1.0.3** (published 2022-03-29) · MIT license · 0 weekly downloads

## Install

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

## 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.3 |
| Published | 2022-03-29 |
| First published | 2022-03-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 7.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Devil64-Dev |
| Maintainers | devil64-dev |
| Keywords | syntax, node-highlight, highlight, react |

## Links

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

## Dependencies (1)

- [node-highlight](https://npm.io/package/node-highlight.md) >=1.0.8

## 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.3 (latest) — 2022-03-29
- 1.0.2 — 2022-03-28
- 1.0.1 — 2022-03-28
- 1.0.0 — 2022-03-25

## README

# node-highlight-react

React parser for [node-highlight](https://github.com/Devil64-Dev/node-highlight.git).

## Installation

yarn: `yarn add node-highlight-react`

npm: `npm install node-highlight-react`

**NOTE**: You should install `node-highlight` if not is already installed.

## Usage

This exports the core highlight functions `highlight`, `highlightSync`, and the
ready to use React component `CodeHighlight`.

The `highlightSync` returns an array of React child's with the properties:
key, className and children. For asynchronous code use `highlight`. See `Element` type
for more help.

The `CodeHighlight` element provides a JSX friendly usage of this parser. Example:}

```jsx
const code = `const Element = () => (
  <>
    <h1>Hello World</h1>
    <p>This is a React Function Component</p>
  </>
);`;

<CodeHighlight language="javascript">
  {code}
</CodeHighlight>
```

Or just using props.

```jsx
<CodeHighlight language="javascript" code={code}/>
```

The component accepts the following props.

- code: String (optional).

- children: String (optional).

- language: Name of the supported language for `node-highlight`.

- className: Custom class name for the `pre` element. Defaults to &#96;`${prefix}${language}`&#96; (optional).

- prefix: String passed to `highlight` function of `node-highlight` (optional).

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