markdown-contents

Generate table of contents for a markdown document.

BSD-3-Clause 11 个版本
安装
npm install markdown-contents
yarn add markdown-contents
pnpm add markdown-contents
bun add markdown-contents
README

Markdown Contents

Travis build status Coveralls NPM version Canonical Code Style Twitter Follow

Generate table of contents for a markdown document.

The underlying implementation is rendering markdown file into HTML and then use Contents. to generate the table of contents.

Usage

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();

版本列表
1.0.11 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