1. metalsmith-markdown
A Metalsmith plugin to convert markdown files.
metalsmith-markdown
Package: metalsmith-markdown
Created by: segmentio
Last modified: Thu, 12 Oct 2023 13:46:31 GMT
Version: 1.3.0
License: MIT
Downloads: 8,446
Repository: https://github.com/segmentio/metalsmith-markdown

Install

npm install metalsmith-markdown
yarn add metalsmith-markdown

metalsmith-markdown

npm version
code style: prettier
metalsmith: core plugin

Known Vulnerabilities

A Metalsmith plugin to convert markdown files.

Installation

 $ npm install metalsmith-markdown

CLI Usage

Install via npm and then add the metalsmith-markdown key to your metalsmith.json plugins with any Marked options you want, like so:

 {
  "plugins": {
    "metalsmith-markdown": {
      "pedantic": false,
      "gfm": true,
      "tables": true,
      "breaks": false,
      "sanitize": false,
      "smartLists": true,
      "smartypants": false,
      "xhtml": false
    }
  }
}

Javascript Usage

Pass options to the markdown plugin and pass it to Metalsmith with the use method:

 var markdown = require('metalsmith-markdown');
var highlighter = require('highlighter');

metalsmith.use(markdown({
  highlight: function(code) {
    return require('highlight.js').highlightAuto(code).value;
  },
  pedantic: false,
  gfm: true,
  tables: true,
  breaks: false,
  sanitize: false,
  smartLists: true,
  smartypants: false,
  xhtml: false
}));

Custom Renderer

metalsmith-markdown uses marked, so to create a custom renderer get an instance of marked.Renderer()

 var markdown = require('metalsmith-markdown');
var marked = require('marked');
var markdownRenderer = new marked.Renderer();

markdownRenderer.image = function (href, title, text) {
return `
  <figure>
    <img src="${href}" alt="${title}" title="${title}" />
    <figcaption>
      <p>${text}</p>
    </figcaption>
  </figure>`;
};

metalsmith.use(markdown({
  renderer: markdownRenderer,
  pedantic: false,
  gfm: true,
  tables: true,
  breaks: false,
  sanitize: false,
  smartLists: true,
  smartypants: false,
  xhtml: false
}));

History

History

License

MIT

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code