# remarkable-react

> React markdown adapter for Remarkable

Latest version **1.4.3** (published 2020-06-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install remarkable-react
pnpm add remarkable-react
yarn add remarkable-react
bun add remarkable-react
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.4.3 |
| Published | 2020-06-02 |
| First published | 2016-09-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 29.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 53 |
| Author | Harrison Hogg |
| Maintainers | hhogg |
| Keywords | md, markdown, remarkable, react |

## Links

- npm: https://www.npmjs.com/package/remarkable-react
- Repository: https://github.com/HHogg/remarkable-react
- Homepage: https://github.com/HHogg/remarkable-react#readme
- Issues: https://github.com/HHogg/remarkable-react/issues
- npm.io page: https://npm.io/package/remarkable-react

## Alternatives

- [@mdxeditor/editor](https://npm.io/package/@mdxeditor/editor.md) — 962.4K weekly downloads
- [mmdb-lib](https://npm.io/package/mmdb-lib.md) — 680.9K weekly downloads
- [playcanvas](https://npm.io/package/playcanvas.md) — 36.2K weekly downloads
- [@glw907/cairn-cms](https://npm.io/package/@glw907/cairn-cms.md) — 967 weekly downloads
- [markdown-to-confluence](https://npm.io/package/markdown-to-confluence.md) — 103 weekly downloads

## Recent versions

- 1.4.3 (latest) — 2020-06-02
- 1.4.2 — 2020-06-02
- 1.4.1 — 2018-12-07
- 1.4.0 — 2018-11-23
- 1.3.1 — 2018-05-29
- 1.3.0 — 2018-03-16
- 1.2.0 — 2018-03-16
- 1.1.0 — 2018-03-01
- 1.0.3 — 2018-02-08
- 1.0.2 — 2018-01-23
- 1.0.1 — 2017-08-24
- 1.0.0 — 2017-08-14
- 0.2.1 — 2017-08-14
- 0.2.0 — 2017-07-01
- 0.1.0 — 2017-05-14
- … 2 more at https://npm.io/package/remarkable-react/versions

## README

# remarkable-react

[![Build Status](https://travis-ci.org/HHogg/remarkable-react.svg?branch=master)](https://travis-ci.org/HHogg/remarkable-react)
[![npm version](https://badge.fury.io/js/remarkable-react.svg)](https://badge.fury.io/js/remarkable-react)
[![Code Climate](https://codeclimate.com/github/HHogg/remarkable-react/badges/gpa.svg)](https://codeclimate.com/github/HHogg/remarkable-react)

A configurable React component renderer for [Remarkable](https://github.com/jonschlinkert/remarkable).


## Install

```
$ yarn add remarkable-react
```


## Usage

Simply instantiate a new RemarkableReactRenderer and replace the standard Remarkable renderer. Like so...

```js
import Remarkable from 'remarkable';
import RemarkableReactRenderer from 'remarkable-react';

const md = new Remarkable();
md.renderer = new RemarkableReactRenderer();

console.log(md.render('# Remarkable rulezz!'));

/*
 * => [
 *  ReactComponent {
 *    type: 'h1',
 *    key: 0,
 *    props: {
 *      children: ['Remarkable ruleszz!']
 *    },
 *  }
 * ]
 */
}
```

### Options

See the configuration options below that can be passed to RemarkableReactRenderer.

```js
new RemarkableReactRenderer({

  // Key generator function used to generate the need React keys
  // Default: return `index`
  keyGen: (token, index) => 'A Key',

  // This enables you to configure the properties that gets passed to
  // the React component. The value can either be a Function, String or Boolean.
  //
  // > Boolean: `true` will pass it through as it is, `false` will not pass it.
  // > String: Used to remap the prop and pass through under the new name.
  // > Function(value, type): Returns an object with new `key` and/or `value`.
  //
  remarkableProps: {
    align: '',    // Default: Function that remaps to style. (For tables)
    alt: '',      // Default: true (for images)
    block: '',    // Default: false
    content: '',  // Default: Function that returns `dangerouslySetInnerHTML` when HTML is enabled.
    hLevel:'',    // Default: false
    href:'',      // Default: true (for links)
    id: '',       // Default: Function that returns href for footnote anchors and id for footnote refs
    level: '',    // Default: false
    lines: '',    // Default: false
    order: '',    // Default: false
    params:'',    // Default: false
    src: '',      // Default: true (for images)
    subId: '',    // Default: false,
    tight: '',    // Default: false
    title: '',    // Default: true (for images and links)
    type:'',      // Default: false
  },

  // Pass in your own React components!
  //
  // Note: At the moment the following are not implemented.
  // * abbreviations
  // * definition lists
  //
  components: {
    a: Component,           // Default: <a />
    blockquote: Component,  // Default: <blockquote />
    br: Component,          // Default: <br />
    code: Component,        // Default: <code />
    del: Component,         // Default: <del />
    em: Component,          // Default: <em />
    h1: Component,          // Default: <h1 />
    h2: Component,          // Default: <h2 />
    h3: Component,          // Default: <h3 />
    h4: Component,          // Default: <h4 />
    h5: Component,          // Default: <h5 />
    h6: Component,          // Default: <h6 />
    html: Component,        // Default: <div />
    img: Component,         // Default: <img />
    ins: Component,         // Default: <ins />
    li: Component,          // Default: <li />
    mark: Component,        // Default: <mark />
    ol: Component,          // Default: <ol />
    p: Component,           // Default: <p />
    pre: Component,         // Default: <pre />
    strong: Component,      // Default: <strong />
    sub: Component,         // Default: <sub />
    sup: Component,         // Default: <sup />
    table: Component,       // Default: <table />
    tbody: Component,       // Default: <tbody />
    td: Component,          // Default: <td />
    th: Component,          // Default: <th />
    thead: Component,       // Default: <thead />
    tr: Component,          // Default: <tr />
    ul: Component,          // Default: <ul />

    /**
     * Custom components that are defined in the tokens
     * section below.
     */
    custom_component: Component
  },

  // This enables you to configure the mapping of remarkable tokens to component (above).
  // The value can either be a Function, String or Array.
  //
  // > Array[String]: Will nest components from parent down.
  // > String: Used to map directly to a single component.
  // > Function(tokenObject, remarkableOptions): Return a string or Component.
  //
  tokens: {

    // Use this to also handle your custom remarkable tokens!
    custom_token: 'custom_component',
  },

  // This enables you to quickly configure how children are rendered for tokens.
  // By default the `content` of a token is mapped to `children`.
  children: {
    footnote_anchor: () => `↩`,
  },
});
```

### Syntax Highlighting

I've tried to keep this renderer unopinionated and impartial to any one highlighting library, but it is still possible to get this working with a set up like...


```jsx
import SyntaxHighlighter from 'library';


const renderer = new RemarkableReactRenderer({
  components: {
    pre: ({ content, params: language }) => (
      <div dangerouslySetInnerHTML={ { __html:
        SyntaxHighlighter.highlight(content, language),
      } } />
    ),
  }
});
```

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