Git Product home page Git Product logo

markdown-contents's Introduction

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

markdown-contents's People

Contributors

gajus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

neac

markdown-contents's Issues

Use ESLint

Remove "jshint" dev dependency from package.json and the gulp task.

sh:

npm install gulp-eslint --save-dev

gulpfile.js:

var eslint = require('gulp-eslint');

gulp.task('lint', function () {
    return gulp
        .src(['./src/*.js', './src/cinemas/*/*.js', './tests/*.js'])
        .pipe(eslint())
        .pipe(eslint.format())
        .pipe(eslint.failOnError());
});

.eslintrc:

{
    "rules": {
        "no-console": 0,
        "no-extra-parens": 2,
        "no-reserved-keys": 2,
        "no-eq-null": 2,
        "no-extend-native": 2,
        "no-process-env": 2,
        "no-self-compare": 2,
        "no-void": 2,
        "no-warning-comments": [1, { "terms": ["todo", "@toto"], "location": "start" }],
        "vars-on-top": 2,
        "wrap-iife": [2, "inside"],
        "global-strict": [2, "always"],
        "new-cap": 0,
        "no-shadow": 0,
        "no-mixed-requires": 0,
        "no-new-require": 2,
        "brace-style": [2, "1tbs"],
        "comma-style": [2, "last"],
        "func-style": [2, "expression"],
        "no-inline-comments": 2,
        "no-lonely-if": 2,
        "no-multiple-empty-lines": 2,
        "no-nested-ternary": 2,
        "one-var": 2,
        "operator-assignment": [2, "always"],
        "padded-blocks": [2, "never"],
        "quote-props": [2, "as-needed"],
        "quotes": [2, "single"],
        "space-after-keywords": [2, "always"],
        "space-before-blocks": [2, "always"],
        "space-in-brackets": [2, "never"],
        "space-in-parens": [2, "never"],
        "space-unary-ops": [2, { "words": true, "nonwords": false }],
        "spaced-line-comment": [2, "always"],
    },
    "env":{
        "mocha": true,
        "node": true
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.