Created
February 15, 2013 15:04
-
-
Save Crisfole/4960896 to your computer and use it in GitHub Desktop.
Very simple way to make a command line markdown renderer using Node.js and Pagedown. Only accepts streams in, not arguments, not files...Handy for langauges with a Popen3 library (write to the stdin, read from the stdout). Needed this so I could use the same library server side (rails) as client side. And because I was too lazy to try and figure…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function createMarkdown() { | |
| var pagedown = require('pagedown'); | |
| var converter = new pagedown.getSanitizingConverter(); | |
| process.stdout.write(converter.makeHtml(lines)); | |
| } | |
| process.stdin.resume(); | |
| process.stdin.setEncoding('utf8'); | |
| var lines = ""; | |
| process.stdin.on('data', function(chunk) { | |
| lines += chunk; | |
| }); | |
| process.stdin.on('end', createMarkdown); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment