0.1.3 • Published 9 years ago
convert-md v0.1.3
convert-md
convert-md is a tool that converts
markdown written files to
either
- HTML
- PNG
convert-md can either be used as a command line tool.
Installation
convert-md can be installed using npm.
$ npm install convert-mdIf you plan to use convert-md as a stand alone tool from the command line, it
is recommended to install it globally:
$ npm install -g convert-mdUsage
As a tool from the command line
$ convert-md file.mdwill create a file file.md.html in your current directory. You can specify
the type of file using the -t option. You can also provide a custom output
file name using the -o option:
$ conver-md -t pdf -o file.pdf file.mdAs a Javascript library from node applications
Import the conversion function:
const convertMd = require("convert-md")convertMd is a function that accepts either one, two or three arguments:
convertMd (markdownString, options, callback)markdownString- a string containing the markdown formatted input stringoptions- an optional object that may contain a keytypedescribing the output type:htmlpdfpng
callback- an optional function that receives two arguments:err- an error object in case something went wrongoutput- aReadableStreamthat containing the generated output
If no callback is given the function returns a EcmaScript 6 Promise object
that resolves to the generated content.
The following snipped demonstrates the usage:
"use strict"
const convertMd = require("convert-md")
convertMd("# Hello world\nof _markdown_", {
type: "html"
})
.then(stream => {
stream.pipe(process.stdout)
})
.catch(err => {
console.error(err)
})