Skip to content

Instantly share code, notes, and snippets.

@jfall76
Created August 13, 2014 17:09
Show Gist options
  • Save jfall76/0d85c94c90170264caa3 to your computer and use it in GitHub Desktop.
Save jfall76/0d85c94c90170264caa3 to your computer and use it in GitHub Desktop.
code that takes either a file or string formatted in markdown
var parser = require('node-markdown');
var fs = require('fs');
var argv = require('optimist').argv;
var file = argv._[0];
var markdown = fs.readFileSync(file, 'UTF-8');
//markdown passed in as a file
markdown = parser.Markdown(markdown);
//markdown passed in as a string
var string = parser.Markdown("**bold** *italic* [link](http://www.neti.ee) `code block`");
console.log("Output from our markdown file:");
console.log(markdown);
console.log("Output from our string:");
console.log(string);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment