Permalink
Browse files

Add optional option argument

  • Loading branch information...
1 parent 89e7e1e commit d5538ab3fe4232aab955894ec07e971584ac0812 @pvorb committed Feb 17, 2012
Showing with 19 additions and 2 deletions.
  1. +10 −2 pandoc.js
  2. +9 −0 test.js
View
@@ -2,8 +2,16 @@ var spawn = require('child_process').spawn;
module.exports = pdc;
-function pdc(src, srcType, destType, cb) {
- var args = [ '-f', srcType, '-t', destType ];
+// pdc(src,
+function pdc(src, from, to, opt, cb) {
+ if (typeof cb == 'undefined')
+ cb = opt;
+
+ var args = [ '-f', from, '-t', to ];
+
+ if (typeof opt == 'object')
+ args = args.concat(opt);
+
var pandoc = spawn('pandoc', args);
var result = '';
View
@@ -1,7 +1,16 @@
var pandoc = require('./pandoc.js');
+// print markdown
pandoc('# Heading', 'markdown', 'html', function (err, result) {
if (err)
throw err;
console.log(result);
});
+
+// show pandoc version
+pandoc('', 'markdown', 'html', [ '-v' ],
+ function (err, result) {
+ if (err)
+ throw err;
+ console.log(result);
+});

0 comments on commit d5538ab

Please sign in to comment.