A markdown to image parser
Last updated 7 months ago by zce .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install m2i 
SYNC missed versions from official npm registry.


Build Status NPM Downloads NPM Version License Dependency Status devDependency Status Code Style

A minimalist markdown to image converter


$ npm install m2i

# or yarn
$ yarn add m2i

People in China can use npm.taobao.org mirror to increase installation speed.


# other configs
puppeteer_download_host = https://npm.taobao.org/mirrors

or env

$ PUPPETEER_DOWNLOAD_HOST=https://npm.taobao.org/mirrors npm i m2i


const m2i = require('m2i')

await m2i('./readme.md')
// readme.md => readme.png

await m2i('./readme.md', { 
  output: './foo.png', 
  width: 1280 
// readme.md => foo.png


m2i(input[, options])


  • Type: string
  • Details: markdown file path


  • Type: string
  • Details: output image path
  • Default: '<input>.png'
  • Type: number
  • Details: output image width
  • Default: 800

CLI Usage

$ npm install m2i -g

# or yarn 
$ yarn global add m2i
$ m2i --help
Usage: m2i <input>

  -V, --version          output the version number
  -o, --output <output>  output filename
  -w, --width <width>    output image width
  -h, --help             display help for command

  $ m2i example.md -o output.png -w 800

or use npx

$ npx m2i example.md -o output.png -w 800

Advanced Usage

By default, the conversion process of markdown does not do extra things. If you want to change the output format, you can customize the template of markdown or HTML in the configuration file.

This is good for customizing some shared content, or import custom style file.

.m2irc example:

markdown: |

  ## License

  Licensed under the MIT License.
html: |
  <link rel="stylesheet" href="https://unpkg.com/github-markdown-css">
  <article class="markdown-body" style="padding: 2.5em">

This configuration file is loaded through cosmoconfig, so you can place the corresponding file according to its rules, such as ~/.m2irc.


Code highlighting

Code highlighting through Prism.


html: |
  <link rel="stylesheet" href="https://unpkg.com/github-markdown-css">
  <link rel="stylesheet" href="https://unpkg.com/prismjs/themes/prism-okaidia.css">
  <article class="markdown-body" style="padding: 2.5em">${content.trim()}</article>
  <script src="https://unpkg.com/prismjs"></script>


  1. Fork it on GitHub!
  2. Clone the fork to your own machine.
  3. Checkout your feature branch: git checkout -b my-awesome-feature
  4. Commit your changes to your own branch: git commit -am 'Add some feature'
  5. Push your work back up to your fork: git push -u origin my-awesome-feature
  6. Submit a Pull Request so that we can review your changes.

NOTE: Be sure to merge the latest from "upstream" before making a pull request!


MIT © 汪磊

Current Tags

  • 0.2.0                                ...           latest (5 months ago)

2 Versions

  • 0.2.0                                ...           5 months ago
  • 0.1.0                                ...           7 months ago
Maintainers (1)
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 0
Last Month 1
Dependencies (5)
Dev Dependencies (1)
Dependents (0)

Copyright 2014 - 2016 © taobao.org |