Install
The best way to install robotskirt is by using npm. If you want to install it globally, remember to include the -g flag.
npm install robotskirt
If you would like to compile it, you can use node's WAF wapper. Read more about how node C/C++ addons work in the node docs.
node-waf configure build
Usage
Currently robotskirt has one main function, toHtml
, that will take a string of markdown and a callback that will be passed the parsed HTML.
var markdown = require('robotskirt');
markdown.toHtml('# Hello World', function (html) {
sys.puts(html);
});
// '<h1>Hello World</h1>\n'
A common use case might be opening a markdown file and then parsing it into HTML.
var fs = require('fs');
var sys = require('sys');
var markdown = require('robotskirt');
fs.readFile('README.mkd', function (err, data) {
markdown.toHtml(data.toString(), function (html) {
sys.puts(html);
});
});
If you would like to parse your markdown synchronously you can use the toHtmlSync
function.
var html = markdown.toHtmlSync("*sync!*");