webpack-remark-loader-js
A Webpack loader for Markdown using remark.
Installation
npm install @outcome-co/webpack-remark-loader
Usage
The loader outputs a javascript object that complies with either mdast or hast according to the options.
// webpack.config.js
{
module: {
rules: [{
test: /\.md$/,
use: [
{
loader: '@outcome-co/webpack-remark-loader',
options: {
// Your options
}
}
]
}]
}
}
Options
const options = {
// Remove empty paragraphs in the Markdown file
// using https://github.com/syntax-tree/mdast-squeeze-paragraphs
// Default: true
squeezeParagraphs: true,
// Remove the position info from the AST
// using https://github.com/syntax-tree/unist-util-remove-position
// Default: true
removePositions: true,
// Convert from mdast to hast
// using https://github.com/syntax-tree/mdast-util-to-hast
//
// Can take 3 values, or null.
//
// 'strip': converts the mdast to hast, removing any inline HTML
// from the original Markdown.
//
// 'raw': converts the mdast to hast, converting inline HTML to
// hast nodes, without sanitization.
//
// 'sanitize': converts the mdast to hast, converting inline HTML to
// hast nodes, removing dangerous tags.
//
// Default: null
hastConversion: null
}
API
Read the API docs here.
Development
Remember to run ./pre-commit.sh
when you clone the repository.