$ npm install @soldair/marky-markdownThe thing npmjs.com uses to clean up READMEs and other markdown files.
package.description as markdown.npm install marky-markdown --save
marky-markdown exports a single function. For basic use, that function takes a single argument: a string to convert.
var marky = require("marky-markdown")
marky("# hello, I'm markdown").html()
The exported function takes an optional options object as its second argument:
marky("some trusted string", {sanitize: false}).html()
The default options are as follows:
{
sanitize: true, // remove script tags and stuff
highlightSyntax: true, // run highlights on fenced code blocks
prefixHeadingIds: true, // prevent DOM id collisions
serveImagesWithCDN: false, // use npm's CDN to proxy images over HTTPS
debug: false, // console.log() all the things
package: null, // npm package metadata
}
marky-markdown always returns the generated HTML document as a cheerio DOM object that can be queried using a familiar jQuery syntax:
var $ = marky("")
$("img").length
// => 1
$("img").attr("src")
// => "cat.png"
Pass in an npm package object to do stuff like rewriting relative URLs
to their absolute equivalent on GitHub, normalizing package metadata
with redundant readme content, etc
var package = {
name: "foo"
name: "foo is a thing"
repository: {
type: "git",
url: "https://github.com/kung/foo"
}
}
marky(
"# hello, I am the foo readme",
{package: package}
).html()
You can use marky-markdown to parse markdown files in the shell. The easiest way to do this is to install globally:
npm i -g marky-markdown
marky-markdown some.md > some.html
npm install
npm test
ISC