Package detail

metalsmith-md

MoOx12MIT2.0.1

Metalsmith plugin to transform markdown to html

metalsmith, metalsmith-plugin

readme

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

changelog

2.0.1 - 2015-05-30

  • Fixed: pattern option now works as expected

2.0.0 - 2015-05-30

  • Changed: engine is now markdown-it
  • Changed: test option is now pattern

1.1.1 - 2015-05-14

  • Fixed: provided & default options are correctly passed and merged

1.1.0 - 2015-05-14

  • Added: some options are passed to the marked instance in a __metalsmith property

1.0.0 - 2015-05-01

✨ Initial release