metalsmith-md

v2.0.1
Metalsmith plugin to transform markdown to html
metalsmith metalsmith-plugin

metalsmith-md Travis Build Status

Metalsmith plugin to transform markdown to html

This plugin do not rename .md files to .html. Please use metalsmith-rename for this.

Installation

$ npm install metalsmith-md

Usage

import Metalsmith from "metalsmith"
import md from "metalsmith-md"

import markdownIt from "markdown-it"
import hljs from "highlight.js"

new Metalsmith("./")
  .use(
    md({
      markdownIt: markdownIt({
        html: true,
        linkify: true,
        typographer: true,
        highlight: (code, lang) => {
          code = code.trim()

          // language is recognized by highlight.js
          if (lang && hljs.getLanguage(lang)) {
            try {
              return hljs.highlight(lang, code).value
            } catch (__) {}
          }

          // fallback to auto
          try {
            return hljs.highlightAuto(code).value
          } catch (__) {}

          // use external default escaping
          return ''
        },
      })
        //.use(...)
        //.use(...)
      ,
    })
  )
  .build(err => {if (err) {throw err}})

Options

pattern (default: /\.(txt|md|markdown)$/)

Allow you to specify which files should be parsed as md

markdownIt (default: markdownIt())

Allow you to specify your markdown-it instance.

Changelog

License

npm i metalsmith-md

Metadata

  • MIT
  • Whatever
  • Maxime Thirouin
  • released 5/29/2015

Downloads

Maintainers