# simple-pandoc

> A thin and simple pandoc wrapper function

Latest version **0.2.0** (published 2018-05-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install simple-pandoc
pnpm add simple-pandoc
yarn add simple-pandoc
bun add simple-pandoc
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2018-05-29 |
| First published | 2016-06-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 10.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Jun |
| Maintainers | noraesae |
| Keywords | pandoc, markdown |

## Links

- npm: https://www.npmjs.com/package/simple-pandoc
- Repository: https://github.com/utatti/simple-pandoc
- Issues: https://github.com/utatti/simple-pandoc/issues
- npm.io page: https://npm.io/package/simple-pandoc

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

- 0.2.0 (latest) — 2018-05-29
- 0.1.0 — 2016-06-09

## README

# simple-pandoc [![Build Status](https://travis-ci.org/utatti/simple-pandoc.svg?branch=master)](https://travis-ci.org/utatti/simple-pandoc)

A thin and simple pandoc wrapper function

## Introduction

`simple-pandoc` provides probably the thinest and simplest Node.js binding for
[pandoc](http://pandoc.org). It just wraps the [`pandoc`](http://pandoc.org/README.html)
command into JavaScript APIs.

It focuses on a very simple use case, and may not provide complicated
functionalities. If they are needed, please check out
[other libraries](https://www.npmjs.com/browse/keyword/pandoc) on npm.

## Install

`simple-pandoc` doesn't provide `pandoc` itself. Please ensure that pandoc
is installed and executable.  To install pandoc, please refer to the
[Installing](http://pandoc.org/installing.html) section in the pandoc
documentation.

To install `simple-pandoc`, use npm.

```
$ npm install simple-pandoc
```

## API

```js
const pandoc = require('simple-pandoc');
```

### Initialize a converter

`pandoc(from, to, ...opts)`

- `from`: `String` a format specified in the pandoc [documentation](http://pandoc.org/MANUAL.html#general-options)
- `to`: `String` a format specified in the pandoc [documentation](http://pandoc.org/MANUAL.html#general-options)
- `opts`: `...String` options specified in the pandoc [documentation](http://pandoc.org/MANUAL.html)
- return: `Function` a converter function

Example:

```js
const htmlToMarkdown = pandoc('html', 'markdown', '--no-highlight', '--key=value', ...);
```

### Convert with a Promise API

`converter(content)`

- `content`: `String|Buffer` content in the `from` format to be converted
- return: `Promise<Buffer>` promised content in the `to` format

Example:

```js
const htmlToMarkdown = pandoc('html', 'markdown');

htmlToMarkdown(fs.readFileSync('index.html'))
  .then(md => {
    console.log(md.toString());
  });
```

Even better with [async/await](https://github.com/tc39/ecmascript-asyncawait):

```js
const htmlToMarkdown = pandoc('html', 'markdown');

async function convert() {
  const html = fs.readFileSync('index.html');
  const md = await htmlToMarkdown(html);
  console.log(md.toString());
}

convert();
```

### Convert with streams

`converter.stream(readStream)`

- `readStream`: [`Readable`](https://nodejs.org/api/stream.html#stream_class_stream_readable)
  a stream conveying content in the `from` format

- return: [`Readable`](https://nodejs.org/api/stream.html#stream_class_stream_readable)
  a stream conveying converted content in the `to` format

Example:

```js
const htmlToMarkdown = pandoc('html', 'markdown');

const inputStream = fs.createReadStream('index.html');
const outputStream = fs.createWriteStream('index.md');
htmlToMarkdown.stream(inputStream).pipe(outputStream);
```

## License

MIT © [Jun](http://github.com/noraesae)

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