2.7.1 • Published 11 years ago

robotskirt v2.7.1

Weekly downloads
93
License
-
Repository
github
Last release
11 years ago

Robotskirt

Robotskirt is a simple node binding for the Sundown markdown parser. It was inspired by the Redcarpet gem released by github.
Eventually Robotskirt should mirror the feature set of redcarpet, currently it doesn't support custom renderers.

Performance

Benchmarked against other popular node markdown libraries by running the entire official markdown test suit 1000 times.

$ node index.js --bench
robotskirt (reuse renderer) completed in 1794ms.
robotskirt (new renderer) completed in 1848ms.
marked completed in 5517ms.
discount completed in 5866ms.
showdown (reuse converter) completed in 13789ms.
showdown (new converter) completed in 17161ms.

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 should use node's WAF wapper. Read more about how node C/C++ addons work in the node docs.

node-waf configure build

Usage

First of all, you need to construct a new HtmlRenderer().
Then, call the markdown function passing as arguments your renderer,
the markdown code to parse, and a callback to handle the result:

var rs = require('robotskirt')
  , util = require('util');

var renderer = new rs.HtmlRenderer();
rs.markdown(renderer, '# Hello World', function (html) {
  util.puts(html);
});
// '<h1>Hello World</h1>\n'

For example, to read and parse a Markdown file:

var rs = require('robotskirt')
  , fs = require('fs')
  , util = require('util');

var renderer = new rs.HtmlRenderer();
fs.readFile('README.mkd', function (err, data) {
  rs.markdown(renderer, data, function (html) {
    util.puts(html);
  });
});

Markdown extension flags

You can pass some flags to Sundown by passing them as an (optional) last argument:

var rs = require('robotskirt')
  , util = require('util');

var renderer = new rs.HtmlRenderer()
  , flags = rs.flags.EXT_FENCED_CODE + rs.flags.EXT_AUTOLINK;
	
rs.markdown(renderer, 'Wow, this becomes http://autolink.ed !', function (html) {
  util.puts(html);
}, flags);

Or, to enable all supported flags, use:

var flags = ~0;

Being synchronous...

If you would like to parse your markdown synchronously you can use the markdownSync function:

var html = rs.markdownSync(new rs.HtmlRenderer(), "*sync!*").toString();

Note: keep in mind that the result is passed as a Buffer rather than a String, so you may convert it to text using toString(), as in this example.

Contributors

License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

2.7.1

11 years ago

2.7.0

11 years ago

2.6.1

12 years ago

2.6.0

12 years ago

2.5.4

12 years ago

2.5.3

12 years ago

2.5.2

12 years ago

2.5.1

12 years ago

2.5.0

12 years ago

2.4.0

12 years ago

2.3.2

12 years ago

1.0.0

12 years ago

0.2.5

12 years ago

0.2.4

12 years ago

0.2.3

12 years ago

0.2.2

13 years ago

0.2.1

13 years ago

0.2.0

13 years ago

0.1.0

13 years ago