1 | #!/usr/bin/env node
|
2 | Styledown = require('..');
|
3 |
|
4 | if (process.argv.indexOf('--css') > -1) {
|
5 | process.stdout.write(require('fs').readFileSync(__dirname + '/../data/styledown.css'));
|
6 |
|
7 | } else {
|
8 | readStdin(function (err, data) {
|
9 | var html = Styledown.parse(data);
|
10 | process.stdout.write(html + "\n");
|
11 | });
|
12 | }
|
13 |
|
14 | function readStdin (fn) {
|
15 | process.stdin.resume(); /* paused by default */
|
16 | process.stdin.setEncoding('utf8');
|
17 |
|
18 | var data = '';
|
19 | process.stdin.on('data', function(chunk) { data += chunk.toString(); });
|
20 | process.stdin.on('end', function() { fn(null, data); });
|
21 | }
|