Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
remark-loader
Advanced tools
Load markdown through remark
.
Simply add the loader to your configuration, and pass options.
import md from "markdown-file.md";
console.log(md);
webpack.config.js
import RemarkHTML from "remark-html";
module.exports = {
// ...
module: {
rules: [
{
test: /\.md$/,
use: [
{
loader: "html-loader",
},
{
loader: "remark-loader",
options: {
remarkOptions: {
plugins: [RemarkHTML],
},
},
},
],
},
],
},
};
Here's the full list of remark
plugins.
We no longer support any react
specific features.
Please see the wonderful MDX project if you're interested in mixing JSX with Markdown.
Name | Type | Default | Description |
---|---|---|---|
remarkOptions | {Object} | {} | Remark options |
removeFrontMatter | {Boolean} | true | Remove removeFrontMatter |
Name | Type | Default | Description |
---|---|---|---|
plugins | Array<String|Array> | [] | Allows to connect remark plugins |
settings | {Object} | undefined | Remark settings |
data | {Object} | undefined | Information available to all plugins |
Type: Array<String\|Array>
Default: []
Allows to connect remark
plugins
webpack.config.js
import RemarkFrontmatter from "remark-frontmatter";
module.exports = {
// ...
module: {
rules: [
{
test: /\.md$/,
use: [
{
loader: "remark-loader",
options: {
remarkOptions: {
plugins: [RemarkFrontmatter],
},
},
},
],
},
],
},
};
If need to specify options for the plugin, can pass the plugin using an array, where the second argument will be options.
webpack.config.js
import RemarkFrontmatter from "remark-frontmatter";
import RemarkBookmarks from "remark-bookmarks";
module.exports = {
// ...
module: {
rules: [
{
test: /\.md$/,
use: [
{
loader: "remark-loader",
options: {
remarkOptions: {
plugins: [
RemarkFrontmatter,
[
RemarkBookmarks,
{
bookmarks: {
npm: "https://npmjs.com/package/remark-bookmarks",
},
},
],
],
},
},
},
],
},
],
},
};
Type: Object
Default: undefined
Pass remark-stringify
options and remark-parse
options options to the remark
.
webpack.config.js
module.exports = {
// ...
module: {
rules: [
{
test: /\.md$/,
use: [
{
loader: "remark-loader",
options: {
remarkOptions: {
settings: {
bullet: "+",
listItemIndent: "1",
},
},
},
},
],
},
],
},
};
Type: Object
Default: undefined
Configure the remark
with information available to all plugins.
Information is stored in an in-memory key-value store.
webpack.config.js
function examplePluginUsingData() {
console.log(this.data);
// { alpha: 'bravo', charlie: 'delta' }
}
module.exports = {
// ...
module: {
rules: [
{
test: /\.md$/,
use: [
{
loader: "remark-loader",
options: {
remarkOptions: {
plugins: [examplePluginUsingData],
data: {
alpha: "bravo",
charlie: "delta",
},
},
},
},
],
},
],
},
};
Type: Boolean
Default: true
By default, the frontMatter is removed.
To override this behavior, set removeFrontMatter
to false
and add remark-frontmatter
to plugins.
webpack.config.js
import RemarkFrontmatter from "remark-frontmatter";
module.exports = {
// ...
module: {
rules: [
{
test: /\.md$/,
use: [
{
loader: "remark-loader",
options: {
removeFrontMatter: false,
remarkOptions: {
plugins: [RemarkFrontmatter],
},
},
},
],
},
],
},
};
This project was inspired the following open source work:
To get html, need to add remark-html
to the remark plugins and add html-loader
to the webpack.config
import md from "markdown-file.md";
console.log(md);
webpack.config.js
import RemarkHTML from "remark-html";
module.exports = {
// ...
module: {
rules: [
{
test: /\.md$/,
use: [
{
loader: "html-loader",
},
{
loader: "remark-loader",
options: {
remarkOptions: {
plugins: [RemarkHTML],
},
},
},
],
},
],
},
};
index.js
import md from "markdown-file.md";
console.log(md);
webpack.config.js
module.exports = {
// ...
module: {
rules: [
{
test: /\.md$/,
use: [
{
loader: "remark-loader",
},
],
},
],
},
};
Please take a moment to read our contributing guidelines if you haven't yet done so.
FAQs
Load markdown through remark with some react-specific features.
The npm package remark-loader receives a total of 12,553 weekly downloads. As such, remark-loader popularity was classified as popular.
We found that remark-loader demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.