Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update examples and add flag arg to toHtml and toHtmlSync. Fixes #12

  • Loading branch information...
commit 41befe48b65757168cad7415538ebf03c5ca8d96 1 parent 02cc8b2
@benmills authored
Showing with 28 additions and 9 deletions.
  1. +24 −5 example.js
  2. +4 −4 index.js
View
29 example.js
@@ -1,17 +1,36 @@
-var markdown = require('./index.js');
+var rs = require('./index.js');
var fs = require('fs');
// Simple examples
-
-markdown.toHtml("# async", function (html) {
+rs.toHtml("# async", function (html) {
process.stdout.write(html);
});
-process.stdout.write(markdown.toHtmlSync("# sync markdown parsing.."));
+process.stdout.write(rs.toHtmlSync("# sync markdown parsing.."));
//Open a file and parse it
fs.readFile('README.mkd', function (err, data) {
- markdown.toHtml(data.toString(), function (html) {
+ 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());
View
8 index.js
@@ -12,12 +12,12 @@ var Robotskirt = {
EXT_STRIKETHROUGH: rs.EXT_STRIKETHROUGH,
EXT_TABLES: rs.EXT_TABLES },
- toHtml: function (markdownText, callback) {
- this.markdown(new this.HtmlRenderer(), markdownText, callback);
+ toHtml: function (markdownText, callback, flags) {
+ this.markdown(new this.HtmlRenderer(), markdownText, callback, flags);
},
- toHtmlSync: function (markdownText) {
- return this.markdownSync(new this.HtmlRenderer(), markdownText);
+ toHtmlSync: function (markdownText, flags) {
+ return this.markdownSync(new this.HtmlRenderer(), markdownText, flags);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.