electron-markdown
Convert GitHub-flavored Markdown to HTML with a few extras
Last updated 4 months ago by hashimoto .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install electron-markdown 
SYNC missed versions from official npm registry.

electron-markdown

electron-markdown is a Node.js module to convert Markdown to HTML. It uses cmark-gfm for HTML generation, and a series of unified plugins to process the resulting HTML.

Installation

Supports Node.js v10 or higher.

npm install electron-markdown

Usage

electron-markdown exports a single function, which takes a Markdown string as its first argument and an options object as its second argument, and returns a Promise that resolves to the resulting HTML.

resultPromise = electronMarkdown(markdown[, options])

  • result: Promise<String> - a Promise resolving to the resulting HTML if parsing and rendering succeeds
  • markdown: String - a string of Markdown to render to HTML
  • options: Object
    • runBefore Array of [remark] plugins - Custom plugins to be run before the commonly used plugins.
    • cmark options to pass to cmark-gfm; will be deeply merged with the default options
    • highlight - Object of rehype-highlight options.

Default options:

{
  cmark: {
    footnotes: true,
    extensions: {
      table: true,
      strikethrough: true,
      autolink: true,
      tagfilter: true
    }
  },
  highlight: {
    ignoreMissing: true,
    aliases: {
      plaintext: ['text'],
    },
  },
}

To disable an option or extension that is enabled by default, provide your own options with a value of false (or an extensions object with the given extension's value set to false). Any options you provide will be merged into the default options, with false values overriding any default true value.

const markdownToHtml = require('electron-markdown')

markdownToHtml(someMarkdown).then(
  function (html) {
    console.log(html)
  },
  function (err) {
    console.error(err)
  }
)

Current Tags

  • 0.8.1                                ...           latest (a month ago)

11 Versions

  • 0.8.1                                ...           a month ago
  • 0.8.0                                ...           2 months ago
  • 0.7.2                                ...           4 months ago
  • 0.7.1                                ...           4 months ago
  • 0.7.0                                ...           4 months ago
  • 0.6.0                                ...           a year ago
  • 0.5.0                                ...           2 years ago
  • 0.4.0                                ...           2 years ago
  • 0.3.0                                ...           2 years ago
  • 0.2.0                                ...           2 years ago
  • 0.1.0                                ...           2 years ago
Downloads
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 1
Last Month 16
Dependencies (7)
Dev Dependencies (6)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |