-
Notifications
You must be signed in to change notification settings - Fork 21
/
example.js
36 lines (27 loc) · 975 Bytes
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
var rs = require('./index.js');
var fs = require('fs');
// Simple examples
rs.toHtml("# async", function (html) {
process.stdout.write(html);
});
process.stdout.write(rs.toHtmlSync("# sync markdown parsing.."));
//Open a file and parse it
fs.readFile('README.mkd', function (err, data) {
rs.toHtml(data.toString(), function (html) {
process.stdout.write(html);
});
});
// Reuse a renderer
var renderer = new rs.HtmlRenderer();
rs.markdown(renderer, "*this is bold* http://www.benmills.org", function (html) {
console.log(html.toString());
});
// Use a flag
rs.markdown(renderer, "*this is bold* http://www.benmills.org", function (html) {
console.log(html.toString());
}, [rs.flags.EXT_AUTOLINK]);
rs.toHtml("*this is bold* http://www.benmills.org", function (html) {
console.log(html.toString());
}, [rs.flags.EXT_AUTOLINK]);
output = rs.toHtmlSync("*this is bold* http://www.benmills.org", [rs.flags.EXT_AUTOLINK]);
console.log(output.toString());