gitbook-parsers
Version:
Includes GitBook parsers and normalize output
75 lines (49 loc) • 2.29 kB
Markdown
# GitBook Parsers
[](http://badge.fury.io/js/gitbook-parsers) [](https://travis-ci.org/GitbookIO/gitbook-parsers)
This Javascript module provides a low level parsing interface for GitBooks. The API is promise-based, and this module can be used in both Node.js and the Browser.
### Parsers
| Parser | Latest Version | Tests |
| ------ | ------- | ----- |
| [Markdown](https://github.com/GitbookIO/gitbook-markdown) | [](http://badge.fury.io/js/gitbook-markdown) | [](https://travis-ci.org/GitbookIO/gitbook-markdown) |
| [AsciiDoc](https://github.com/GitbookIO/gitbook-asciidoc) | [](http://badge.fury.io/js/gitbook-asciidoc) | [](https://travis-ci.org/GitbookIO/gitbook-asciidoc) |
| [reStructuredText](https://github.com/GitbookIO/gitbook-restructuredtext) | [](http://badge.fury.io/js/gitbook-restructuredtext) | [](https://travis-ci.org/GitbookIO/gitbook-restructuredtext) |
### Usage
This module can be used in **node.js** and in the **browser**
##### In the Browser:
Include the file:
```
<script src="library/gitbook-parsers.min.js" />
```
##### In Node.js:
```
npm install gitbook-parsers
```
Then include it using:
```js
var gitbookParsers = require("gitbook-parsers");
```
##### Find a parser for a file:
```js
var parser = gitbookParsers.getForFile("FILE.md");
```
##### Use this parser:
Parse the summary:
```js
parser.summary("* [An entry](./test.md)")
.then(function(summary) { ... });
```
Parse the glossary:
```js
parser.glossary("...")
.then(function(glossary) { ... });
```
Parse the languages index:
```js
parser.langs("...")
.then(function(languages) { ... });
```
Parse a page to html:
```js
parser.page("...")
.then(function(sections) { ... });
```