1 | #!/usr/bin/env node
|
2 | (function () {
|
3 | "use strict";
|
4 |
|
5 | var fs = require('fs')
|
6 | , markdown = require('markdown').markdown
|
7 | , fullpath = process.argv[2]
|
8 | ;
|
9 |
|
10 | function convert(err, data) {
|
11 | var md
|
12 | , html
|
13 | ;
|
14 |
|
15 | if (err) {
|
16 | throw err;
|
17 | }
|
18 |
|
19 | md = data.toString('utf8');
|
20 | html = markdown.toHTML(md);
|
21 | console.log(html);
|
22 | }
|
23 |
|
24 | if (!fullpath) {
|
25 | console.error('try: ', process.argv[1].split('/').pop(), '/path/to/doc.md');
|
26 | return;
|
27 | }
|
28 |
|
29 | fs.readFile(fullpath, convert);
|
30 | }())
|