包详细信息

metalsmith-markdown

segmentio6kMIT1.3.0

A Metalsmith plugin to convert markdown files.

自述文件

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

更新日志

Latest

Check for unreleased changes.

1.3.0 - 2019-10-30

  • Updated packages
    • marked v0.7.0
    • eslint
    • eslint-config-prettier
    • eslint-plugin-prettier
    • mocha
    • prettier

1.2.0 - 2019-02-20

  • Docs updated
  • Updated packages
    • debug
    • marked
    • eslint
    • eslint-config-prettier
    • eslint-plugin-prettier
    • mocha
    • prettier

Previous

1.1.0 - 2018-10-26

  • Updated packages
    • debug
    • marked
    • eslint
    • eslint-config-prettier
    • eslint-plugin-prettier
    • prettier

1.0.1 - 2018-09-14

  • Added Prettier and ESLint
  • Updated Badges
  • Updated debug package

1.0.0 - 2018-07-17

  • Fixed API
  • Upgraded to Marked 0.4.0 #31
  • Fixed security issue with Buffer #29
  • Ensure key is string #24
  • Cross platform path separators (Windows) #16
  • Strict file endings #10
  • Allow missing keys #9
  • Docs: Usage with highlighting lib #6
  • Updated all packages

0.2.2 - 2018-01-09

  • update marked dependency to fix security issue

0.2.1 - February 6, 2013

  • add debug statements

0.2.0 - February 5, 2013

  • update to use buffers for metalsmith 0.1.0

0.1.0 - February 5, 2013

  • add keys option

0.0.1 - February 4, 2013


:sparkles: