# rebber

> Stringifies MDAST to LaTeX

Latest version **5.5.0** (published 2024-04-27) · MIT license · 0 weekly downloads

## Install

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

## 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 | 5.5.0 |
| Published | 2024-04-27 |
| First published | 2017-06-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 40.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Victor Felder |
| Maintainers | situphen, talone |
| Keywords | mdast, latex |

## Links

- npm: https://www.npmjs.com/package/rebber
- Repository: https://github.com/zestedesavoir/zmarkdown.git#master
- Homepage: https://github.com/zestedesavoir/zmarkdown/tree/master#readme
- Issues: https://github.com/zestedesavoir/zmarkdown/issues
- npm.io page: https://npm.io/package/rebber

## Dependencies (6)

- [has](https://npm.io/package/has.md) ^1.0.3
- [clone](https://npm.io/package/clone.md) ^2.1.2
- [xtend](https://npm.io/package/xtend.md) ^4.0.2
- [trim-lines](https://npm.io/package/trim-lines.md) ^1.1.3
- [collapse-white-space](https://npm.io/package/collapse-white-space.md) ^1.0.6
- [mdast-util-definitions](https://npm.io/package/mdast-util-definitions.md) ^3.0.1

## 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

- 5.5.0 (latest) — 2024-04-27
- 5.4.0 — 2023-07-05
- 5.3.0 — 2022-03-29
- 5.2.1 — 2021-08-30
- 5.2.0 — 2021-02-14
- 5.1.2 — 2020-06-29
- 5.1.1 — 2020-05-27
- 5.1.0 — 2020-02-28
- 5.0.0 — 2020-02-03
- 4.0.2 — 2020-01-21
- 4.0.0 — 2020-01-21
- 3.1.5 — 2019-08-29
- 3.1.4 — 2019-07-27
- 3.1.3 — 2019-04-14
- 3.1.2 — 2019-02-04
- … 52 more at https://npm.io/package/rebber/versions

## README

# rebber [![Build Status][build-badge]][build-status] [![Coverage Status][coverage-badge]][coverage-status]


**rebber** is a LaTeX stringifier for [remark][]

## remark-rebber version compatibility

Starting from version 8.0.0, `remark` dropped support for footnotes; hence, `rebber` also dropped it's support starting from version 6.0.0.

Therefore, we have the following compatibility table for remark-rebber versions:

| remark  | rebber  |
| ------- | ------- |
| < 8.0.0 | < 6.0.0 |
| > 8.0.0 |   any   |

## Installation

[npm][]:

```bash
npm install rebber
```

## Usage

```javascript
const unified = require('unified')
const remarkParser = require('remark-parse')
const rebber = require('rebber')

const {contents} = unified()
  .use(remarkParser)
  .use(rebber)
  .processSync('### foo')

console.log(contents);
```

Yields:

```latex
\section{foo}
```

## API

### `toLaTeX(node[, options])`

Stringify the given [MDAST node][mdast].


#### `options.overrides`

Overrides are named that way because they can override any MDAST node type to latex stringifier. Their other use is to use custom latex stringifier for custom MDAST node type.

Examples:

```js
const {contents} = unified()
  .use(remarkParser)
  .use(remarkFoobarElementsParser) // creates MDAST nodes of type 'foobar'
  .use(rebber, {
    overrides: {
      // override rebber's method to turn MDAST link nodes into latex
      link: require('./your-own-link-latexifier')
      // tell rebber what to use to turn MDAST foobar nodes into latex
      foobar: require('./your-foobar-latexifier')
    }
  })

```

#### `options.<mdastNodeType>`

[MDAST nodes][mdast] are stringified to LaTeX using sensible default LaTeX commands. However, you can customize most of the LaTeX command corresponding to MDAST nodes. Here are documented the function signatures of these customizable commands. Note that the keys of the `options` object are named after the corresponding MDAST node type.

For example, by default, `![](/foo.png)` will get compiled to `\includegraphics{/foo.png}`.

Setting
```js
options.image = (node) => `[inserted image located at "${node.url}"]`
```

will stringify our example Markdown to `[inserted image located at "/foo.png"]` instead of `\includegraphics{/foo.png}`.

###### `options.blockquote`

    (text) => ``,

###### `options.break`

    () => ``,

###### `options.code`

    (textCode, lang) => ``,

###### `options.definition`

    (options, identifier, url, title) => ``,

###### `options.footnote`

    (identifier, text, protect) => ``,

###### `options.footnoteDefinition`

    (identifier, text) => ``,

###### `options.footnoteReference`

    (identifier) => ``,

###### `options.headings`

    [
      (text) => ``, // level 1 heading
      (text) => ``, // level 2 heading
      (text) => ``, // level 3 heading
      (text) => ``, // level 4 heading
      (text) => ``, // level 5 heading
      (text) => ``, // level 6 heading
      (text) => ``, // level 7 heading
    ],

###### `options.image`

    (node) => ``,

###### `options.link`

    (displayText, url, title) => ``,

###### `options.linkReference`

    (reference, content) => ``,

###### `options.list`

    (content, isOrdered) => ``,

###### `options.listItem`

    (content) => ``,

###### `options.text`

    (text) => ``,

###### `options.thematicBreak`

    () => ``,

###### `options.table`

    (ctx, node) => ``,

Table stringification can be configured with some advanced options:

###### `options.tableEnvName`

    `longtblr`

Name of the environment to be used for tables.
Allows defining custom environments in LaTeX with `\NewTblrEnviron`.
To ensure a flexible rendering, the `longtblr` environment is used by default.

###### `options.headerCounter: (node) => 1`

    (tableRows) => 1

Function that counts the number of header rows (rows that should be emphasized).

###### `options.headerProperties`

    `font=\bfseries`

LaTeX properties added to header rows, follows the syntax of the underlying LaTeX package.

###### `options.headerParse`

    (tableRows) => ``

Function that computes the "latex header" part of the table environment, this generates strings such as `|c|c|r|`.
It gets an array of all the `tableRow` [mdast] nodes for the table as argument.
Default function extracts the number of columns for each row and uses the `X[-1]` handler ("find the best available width").
The result for a 3 column-table is `|X[-1]|X[-1]|X[-1]|`.


## Related

*   [`rebber-plugins`][rebber-plugins]
    - A collection of rebber plugins able to stringify custom Remark node types.

## License

[MIT][license] © [Zeste de Savoir][zds]

<!-- Definitions -->

[build-badge]: https://img.shields.io/travis/zestedesavoir/zmarkdown.svg

[build-status]: https://travis-ci.org/zestedesavoir/zmarkdown

[coverage-badge]: https://img.shields.io/coveralls/zestedesavoir/zmarkdown.svg

[coverage-status]: https://coveralls.io/github/zestedesavoir/zmarkdown

[license]: https://github.com/zestedesavoir/zmarkdown/blob/master/packages/rebber/LICENSE-MIT

[rebber-plugins]: https://github.com/zestedesavoir/zmarkdown/blob/master/packages/rebber-plugins

[zds]: https://zestedesavoir.com

[npm]: https://www.npmjs.com/package/rebber

[mdast]: https://github.com/syntax-tree/mdast/blob/master/readme.md

[remark]: https://github.com/remarkjs/remark

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