npm

npm’s 2019 JavaScript ecosystem survey analysis is now available! Get your copy here »

markdown-contents

1.0.11 • Public • Published

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

install

npm i markdown-contents

Downloadsweekly downloads

493

version

1.0.11

license

BSD-3-Clause

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability