A lightweight utility for inserting blocks of text into markdown files.
OTHER License
markdown-decorator
[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![License][license-image]][license-url]
A lightweight utility for inserting text into markdown files and templates.
$ npm install --save markdown-decorator
const MarkdownDecorator = require('markdown-decorator')
const fs = require('fs')
const pkg = require('./package')
const decorator = new MarkdownDecorator(fs.readFileSync('README.md'))
## 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.
Use toc
comment tags as delimiters:
## Table of contents
<!-- toc -->
<!-- tocend -->
decorator.toc(markdown)
const md = decorator
.semver(pkg.version)
.toc(markdown)
.toString()
<%= 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'
})
# `<!-- title --><!-- titleend -->`
decorator.insert('markdown-decorator', {
open: 'title',
close: 'titleend'
})
decorator.markdown
// => # `<!-- title -->markdown-decorator<!-- titleend -->`
markdown-decorator
is at v1.0.0
. Please see the CHANGELOG for details.
[![PRs Welcome][makeapullrequest-image]][makeapullrequest-url] 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.
[![License][license-image]][license-url] Greg Swindle
[issues-url]: (https://github.com/gregswindle/markdown-decorator/issues [license-image]: https://img.shields.io/badge/License-Apache%202.0-blue.svg?style=flat [license-url]: ./LICENSE [makeapullrequest-image]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square [makeapullrequest-url]: http://makeapullrequest.com [new-issue-url]: https://github.com/gregswindle/markdown-decorator/issues/new [npm-image]: https://badge.fury.io/js/markdown-decorator.svg [npm-url]: https://npmjs.org/package/markdown-decorator [pr-course-url]: https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github [pr-url]: https://github.com/gregswindle/markdown-decorator/pulls [pr-url]: https://github.com/gregswindle/markdown-decorator/pulls [standard-version-url]: https://github.com/conventional-changelog/standard-version [travis-image]: https://travis-ci.org/gregswindle/markdown-decorator.svg?branch=master [travis-url]: https://travis-ci.org/gregswindle/markdown-decorator