Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
pvorb committed Feb 13, 2012
0 parents commit a4c5c03
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 0 deletions.
18 changes: 18 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Copyright © 2012 Paul Vorbach <paul@vorb.de> (http://vorb.de)

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the “Software”), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 changes: 24 additions & 0 deletions README.mkd
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# pdc

a pandoc wrapper for node.js

# License

Copyright © 2012 Paul Vorbach

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the “Software”), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 changes: 24 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "pdc",
"description": "a pandoc wrapper for node",
"author": "Paul Vorbach <paul@vorb.de> (http://vorb.de/)",
"tags": [ "pandoc", "markdown" ],
"version": "0.0.0",
"repository": {
"type": "git",
"url": "git://github.com/pvorb/node-pandoc.git"
},
"bugs": {
"url": "https://github.com/pvorb/node-pandoc/issues"
},
"main": "./pandoc.js",
"engines": {
"node": ">=0.6.0"
},
"licenses": [
{
"type": "MIT",
"url": "http://vorb.de/license/mit.html"
}
]
}
29 changes: 29 additions & 0 deletions pandoc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
var spawn = require('child_process').spawn;

module.exports = pdc;

function pdc(src, srcType, destType, cb) {
var args = [ '-f', srcType, '-t', destType ];
var pandoc = spawn('pandoc', args);

var result = '';
var error = '';

pandoc.stdout.on('data', function (data) {
result += data;
});
pandoc.stderr.on('data', function (data) {
error += data;
});

pandoc.on('exit', function (code) {
if (code != 0)
return cb(new Error('pandoc exitet with code '+code+'.'));
if (error)
return cb(new Error(error));

cb(null, result);
});

pandoc.stdin.end(src, 'utf8');
}
7 changes: 7 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
var pandoc = require('./pandoc.js');

pandoc('# Heading', 'markdown', 'html', function (err, result) {
if (err)
throw err;
console.log(result);
});

0 comments on commit a4c5c03

Please sign in to comment.