markdown-decorator

    1.0.0 • Public • Published

    markdown-decorator

    NPM version Build Status Windows build status Dependency Status Codacy Badge Coverage percentage License

    A lightweight utility for inserting text into markdown files and templates.

    Table of contents

    1. Installation

    $ npm install --save markdown-decorator

    2. Usage

    2.1. Pass a markdown string to its constructor

    const MarkdownDecorator = require('markdown-decorator')
    const fs = require('fs')
    const pkg = require('./package')
     
    const decorator = new MarkdownDecorator(fs.readFileSync('README.md'))
     

    2.2. Insert your product's (semantic) version

    ## Version and CHANGELOG
     
    `markdown-decorator`'s latest version is
    <!-- semver -->
    <!-- semverend -->.
    Please read the [CHANGELOG][changelog-url] for details.
    // pkg.version === '1.1.0-alpha.1'
    decorator.semver(pkg.version)

    Inserts the semver:

    ## Version and CHANGELOG
     
    `markdown-decorator`'s latest version is
    <!-- semver -->1.1.0-alpha.1<!-- semverend -->.
    Please read the [CHANGELOG][changelog-url] for details.

    2.3. Generate a table of contents

    Use toc comment tags as delimiters:

    ## Table of contents
    <!-- toc -->
    <!-- tocend -->
    decorator.toc(markdown)

    2.4. Method chaining

    const md = decorator
      .semver(pkg.version)
      .toc(markdown)
      .toString()

    2.5. Templates

    <%= header %>
    <%= body %>
    ---
    <%= footer %>

    Use the decorate method with an object literal to insert values in your template:

    const md = decorator.decorate({
      version: '1.0.0'
    })
    .toString({
      template,
      header: '# TEMPLATE HEADER',
      body: decorator.markdown,
      footer: 'TEMPLATE FOOTER'
    })

    2.6. Insert a string between delimiters

    # `<!-- title --><!-- titleend -->`
    decorator.insert('markdown-decorator', {
        open: 'title',
        close: 'titleend'
    })
    decorator.markdown
    // => # `<!-- title -->markdown-decorator<!-- titleend -->`

    3. Version and CHANGELOG

    markdown-decorator is at v1.0.0. Please see the CHANGELOG for details.

    4. Contributing

    PRs Welcome We welcome contributors and pull requests. Check out the guidelines for

    Contributions are stories with a beginning, a middle, and an end, all told through issues, comments, commit logs, and pull requests.

    5. License

    License © Greg Swindle


    Greenkeeper badge

    Install

    npm i markdown-decorator

    DownloadsWeekly Downloads

    0

    Version

    1.0.0

    License

    Apache-2.0

    Last publish

    Collaborators

    • gregswindle