diff --git a/bin/remarkable.js b/bin/remarkable.js index b1899f2..d1202ca 100755 --- a/bin/remarkable.js +++ b/bin/remarkable.js @@ -12,7 +12,7 @@ var Remarkable = require('..'); //////////////////////////////////////////////////////////////////////////////// var cli = new argparse.ArgumentParser({ - prog: 'js-yaml', + prog: 'remarkable', version: require('../package.json').version, addHelp: true }); diff --git a/bin/specsplit.js b/bin/specsplit.js new file mode 100755 index 0000000..a8af764 --- /dev/null +++ b/bin/specsplit.js @@ -0,0 +1,115 @@ +#!/usr/bin/env node +/*eslint no-console:0*/ + +// Fixtures generator from stmd specs. Split spec to working / not working +// examples, or show total stat. + +'use strict'; + + +var fs = require('fs'); +var util = require('util'); +var argparse = require('argparse'); + +var Remarkable = require('..'); + + +var cli = new argparse.ArgumentParser({ + prog: 'specsplit', + version: require('../package.json').version, + addHelp: true +}); + +cli.addArgument([ 'type' ], { + help: 'type of examples to filter', + nargs: '?', + choices: [ 'good', 'bad' ] +}); + +cli.addArgument([ 'spec' ], { + help: 'spec file to read' +}); + +var options = cli.parseArgs(); + +//////////////////////////////////////////////////////////////////////////////// + +function readFile(filename, encoding, callback) { + if (options.file === '-') { + // read from stdin + + var chunks = []; + + process.stdin.on('data', function(chunk) { + chunks.push(chunk); + }); + + process.stdin.on('end', function() { + return callback(null, Buffer.concat(chunks).toString(encoding)); + }); + } else { + fs.readFile(filename, encoding, callback); + } +} + + +//////////////////////////////////////////////////////////////////////////////// + +readFile(options.spec, 'utf8', function (error, input) { + var good = [], bad = [], + markdown = new Remarkable({ + xhtml: true, // write