<commit_before># toc-md [![Build Status](https://travis-ci.org/eGavr/toc-md.svg)](https://travis-ci.org/eGavr/toc-md) [![Coverage Status](https://img.shields.io/coveralls/eGavr/toc-md.svg)](https://coveralls.io/r/eGavr/toc-md?branch=master) [![Dependency Status](https://david-dm.org/eGavr/toc-md.svg)](https://david-dm.org/eGavr/toc-md) [![devDependency Status](https://david-dm.org/eGavr/toc-md/dev-status.svg)](https://david-dm.org/eGavr/toc-md#info=devDependencies)

Generates a markdown TOC (table of contents).

The tool can be used for English and Russian languages.

<!-- TOC -->
- [Install](#install)
- [Usage](#usage)
  - [API](#api)
    - [toc.insert](#tocinsert)
    - [toc.clean](#tocclean)
    - [Example](#example)
  - [CLI](#cli)
    - [Insert](#insert)
    - [Clean](#clean)
- [Advanced TOC](#advanced-toc)
  - [Ignoring of headers](#ignoring-of-headers)
  - [Displaying of headers](#displaying-of-headers)

<!-- TOC END -->

## Install

```bash
$ npm install toc-md
```

## Usage

Add an HTML comment `<!-- TOC -->` to a markdown file.

A TOC will be generated exactly on this place for the following headers.

### API

```js
var toc = require('toc-md');
```

#### toc.insert

**@param** *{String}* - a source where to insert a TOC (must contain the HTML comment `<!-- TOC -->`)<br>
**@param** *{Object}* - options:<br>

 * **maxDepth: Number** - makes `toc-md` use headings whose depth is at most the specified value (default: `6`).

 * **bullet: Char** - the bullet (`*`, `-`, `+`) to use for each element in the generated TOC (defaults: `-`).

**@param** *{Function}* - callback

#### toc.clean

**@param** *{String}* - a source whereof to clean a TOC<br>
**@param** *{Function}* - callback

#### Example

```js
var fs = require('fs'),
    toc = require('toc-md');

var source = fs.readFileSync('markdown-without-toc.md', 'utf-8');

var options = {
    maxDepth: 6
};

toc.insert(source, options, function (err, res) {
    if (err) {
        console.log(err);
    } else {
        fs.writeFileSync('markdown-with-toc.md', res);
    }<commit_msg>Fix docs<commit_after># toc-md [![Build Status](https://travis-ci.org/eGavr/toc-md.svg)](https://travis-ci.org/eGavr/toc-md) [![Coverage Status](https://img.shields.io/coveralls/eGavr/toc-md.svg)](https://coveralls.io/r/eGavr/toc-md?branch=master) [![Dependency Status](https://david-dm.org/eGavr/toc-md.svg)](https://david-dm.org/eGavr/toc-md) [![devDependency Status](https://david-dm.org/eGavr/toc-md/dev-status.svg)](https://david-dm.org/eGavr/toc-md#info=devDependencies)

Generates a markdown TOC (table of contents).

The tool can be used for English and Russian languages.

<!-- TOC -->
- [Install](#install)
- [Usage](#usage)
  - [API](#api)
    - [toc.insert](#tocinsert)
    - [toc.clean](#tocclean)
    - [Example](#example)
  - [CLI](#cli)
    - [Insert](#insert)
    - [Clean](#clean)
- [Advanced TOC](#advanced-toc)
  - [Ignoring of headers](#ignoring-of-headers)
  - [Displaying of headers](#displaying-of-headers)

<!-- TOC END -->

## Install

```bash
$ npm install toc-md
```

## Usage

Add an HTML comment `<!-- TOC -->` to a markdown file.

A TOC will be generated exactly on this place for the following headers.

### API

```js
var toc = require('toc-md');
```

#### toc.insert

**@param** *{String}* - a source where to insert a TOC (must contain the HTML comment `<!-- TOC -->`)<br>
**@param** *{Object}* - options:<br>

 * **maxDepth: Number** - makes `toc-md` use headings whose depth is at most the specified value (default: `6`).

 * **bullet: Char** - the bullet (`*`, `-`, `+`) to use for each element in the generated TOC (default: `-`).

**@param** *{Function}* - callback

#### toc.clean

**@param** *{String}* - a source whereof to clean a TOC<br>
**@param** *{Function}* - callback

#### Example

```js
var fs = require('fs'),
    toc = require('toc-md');

var source = fs.readFileSync('markdown-without-toc.md', 'utf-8');

var options = {
    maxDepth: 6
};

toc.insert(source, options, function (err, res) {
    if (err) {
        console.log(err);
    } else {
        fs.writeFileSync('markdown-with-toc.md', res);
    }
{'fraction_non_alphanumeric': 0.21328162869607367, 'fraction_numerical': 0.001454192922927775, 'mean_word_length': 3.6370786516853935, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 16, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6658397', 'n_tokens_mistral': 1605, 'n_tokens_neox': 1496, 'n_words': 345}