reshape-markdown
v1.1.1
Published
Include markdown files into your reshape templates
Downloads
7
Readme
Reshape Markdown Parser
A parser for the reshape include plugin that allows you to include markdown files into your HTML, uses the markdown-it parser by default.
Install
npm i --save reshape-markdown
Usage
Given an index.html
such as:
<p>Partial:</p>
<include src='docs/readme/_partial.md'></include><p>after the partial</p>
And a _partial.md
file like:
**hello from the partial!**
You can process them with reshape:
const {readFileSync} = require('fs')
const reshape = require('reshape')
const include = require('reshape-include')
const markdown = require('reshape-markdown')
const html = readFileSync('docs/readme/index.html')
reshape({
plugins: [
include({
parserRules: [
{
test: /\.md$/,
parser: markdown()
}
]
})
]
})
.process(html)
.then((result) => console.log(result.output()))
Generates the output:
<p>Partial:</p>
<p><strong>hello from the partial!</strong></p>
<p>after the partial</p>
Options
parser
: Markdown parser, must expose arender()
function.markdown
: Options to pass when instantiating the markdown-it instance.
License
MIT
Created by mkdoc on February 20, 2017