# drafter

> Node API Blueprint Parser

Latest version **2.0.0** (published 2020-03-17) · MIT license · 0 weekly downloads

## Install

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

## 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 | 2.0.0 |
| Published | 2020-03-17 |
| First published | 2015-03-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 4 |
| Dependencies | 2 |
| Unpacked size | 5.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 35 |
| Author | Apiary Czech Republic, s.r.o. |
| Maintainers | apiary-sre, danielgtaylor, kylef, pksunkara, zdne |

## Links

- npm: https://www.npmjs.com/package/drafter
- Repository: https://github.com/apiaryio/drafter-npm
- Issues: https://github.com/apiaryio/drafter-npm/issues
- npm.io page: https://npm.io/package/drafter

## Dependencies (2)

- [drafter.js](https://npm.io/package/drafter.js.md) ^3.0.2
- [protagonist](https://npm.io/package/protagonist.md) ^2.0.2

## Recent versions

- 2.0.0 (latest) — 2020-03-17
- 2.0.0-pre.1 — 2018-11-20
- 2.0.0-pre.0 — 2018-09-12
- 1.2.0 — 2016-10-31
- 1.1.0 — 2016-09-08
- 1.0.0 — 2016-07-19
- 0.2.8-refract1 — 2015-07-31
- 0.2.8 — 2015-06-11
- 0.2.7 — 2015-05-15
- 0.2.6 — 2015-04-30
- 0.2.5 — 2015-04-16
- 0.2.4 — 2015-04-14
- 0.2.3 — 2015-04-10
- 0.2.2 — 2015-04-08
- 0.2.1 — 2015-04-02
- … 3 more at https://npm.io/package/drafter/versions

## README

![logo](https://raw.github.com/apiaryio/api-blueprint/master/assets/logo_apiblueprint.png)

# Drafter NPM Package [![Build Status](https://travis-ci.org/apiaryio/drafter-npm.svg?branch=master)](https://travis-ci.org/apiaryio/drafter-npm)

The Drafter NPM package is an API Blueprint parser for Node. This package is a
wrapper around the underlying C++ parser
[Drafter](https://github.com/apiaryio/drafter). Drafter NPM optionally depends
on the C++ binding to Drafter
[Protagonist](https://github.com/apiaryio/protagonist). If for any reason
Protagonist is not installable, this package will fallback to using the slower,
pure JavaScript version of Drafter,
[drafter.js](https://github.com/apiaryio/drafter.js).

## Installation

Drafter can be installed from NPM. If you want to use Drafter from a web
browser, check out [drafter.js](https://github.com/apiaryio/drafter.js).

```shell
$ npm install drafter
```

## Usage

```js
var drafter = require('drafter');
```

Once you've included drafter, you can parse an API Blueprint asynchronously:

```js
var options = {
  generateSourceMap: true,
};

drafter.parse('# API Blueprint...', options, function(err, result) {
  if (err) {
    console.log(err);
  } else {
    console.log(result);
  }
});
```

Alternatively, you can use Drafter synchronously:

```js
try {
  var result = drafter.parseSync('# API Blueprint...', options);
  console.log(result);
} catch (err) {
  console.log(err);
}
```

### Parsing Options

Options can be passed to the parser as an optional second argument to both the
asynchronous and synchronous interfaces:

```js
var options = {
  generateSourceMap: true
}

drafter.parse('# My API', options, callback);
```

The available options are:

Name                   | Description
---------------------- | ----------------------------------------------------------
`requireBlueprintName` | Require parsed blueprints have a title (default: false)
`generateSourceMap`    | Enable sourcemap generation (default: false)

## License

MIT License. See the [LICENSE](LICENSE) file.

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