# markdown-contents

> Generate table of contents for a markdown document.

Latest version **1.0.11** (published 2018-08-30) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install markdown-contents
pnpm add markdown-contents
yarn add markdown-contents
bun add markdown-contents
```

## 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 | 1.0.11 |
| Published | 2018-08-30 |
| First published | 2014-11-21 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 9.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Gajus Kuizinas |
| Maintainers | gajus |
| Keywords | table of contents, contents, toc, markdown |

## Links

- npm: https://www.npmjs.com/package/markdown-contents
- Repository: https://github.com/gajus/markdown-contents
- Homepage: https://github.com/gajus/markdown-contents#readme
- Issues: https://github.com/gajus/markdown-contents/issues
- npm.io page: https://npm.io/package/markdown-contents

## Dependencies (2)

- [lodash](https://npm.io/package/lodash.md) ^4.17.10
- [contents](https://npm.io/package/contents.md) ^5.0.0

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

- 1.0.11 (latest) — 2018-08-30
- 1.0.10 — 2016-08-30
- 1.0.9 — 2016-08-30
- 1.0.8 — 2015-10-01
- 1.0.7 — 2015-09-10
- 1.0.6 — 2015-09-10
- 1.0.5 — 2014-11-21
- 1.0.4 — 2014-11-21
- 1.0.3 — 2014-11-21
- 1.0.2 — 2014-11-21
- 1.0.1 — 2014-11-21

## README

## Markdown Contents

[![Travis build status](http://img.shields.io/travis/gajus/markdown-contents/master.svg?style=flat-square)](https://travis-ci.org/gajus/markdown-contents)
[![Coveralls](https://img.shields.io/coveralls/gajus/markdown-contents.svg?style=flat-square)](https://coveralls.io/github/gajus/markdown-contents)
[![NPM version](http://img.shields.io/npm/v/markdown-contents.svg?style=flat-square)](https://www.npmjs.org/package/markdown-contents)
[![Canonical Code Style](https://img.shields.io/badge/code%20style-canonical-blue.svg?style=flat-square)](https://github.com/gajus/canonical)
[![Twitter Follow](https://img.shields.io/twitter/follow/kuizinas.svg?style=social&label=Follow)](https://twitter.com/kuizinas)

Generate table of contents for a markdown document.

The underlying implementation is rendering markdown file into HTML and then use [Contents](https://github.com/gajus/contents).
 to generate the table of contents.

## Usage

```js
import MarkdownContents from 'markdown-contents';

const markdown = '';
const markdownContents = MarkdownContents(markdown);

/**
 * Generate flat index of the headings.
 *
 * @return {Array}
 */
markdownContents.articles();

/**
 * Generates hierarchical index of the headings from a flat index.
 *
 * @return {Array}
 */
markdownContents.tree();

/**
 * Generate markdown for the table of contents.
 *
 * @return {string}
 */
markdownContents.markdown();

/**
 * Generate markdown contents for an array of contents object definition.
 *
 * @param {Array} tree [{id: '', name: '', descendants: []}]
 * @return {string} markdown
 */
MarkdownContents.treeToMarkdown();

/**
 * Makes hierarchical index of the articles from a flat index.
 *
 * @param {Array} articles Generated using Contents.articles.
 * @param {boolean} makeUniqueIDs
 * @param {Array} uniqueIDpool
 * @return {Array}
 */
MarkdownContents.tree();

```

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