Skip to content
Browse files

Initial commit

  • Loading branch information...
0 parents commit a4c5c03f07ff0979b35de1eccf449c8b660dd0bd @pvorb committed
Showing with 102 additions and 0 deletions.
  1. +18 −0 LICENSE
  2. +24 −0 README.mkd
  3. +24 −0 package.json
  4. +29 −0 pandoc.js
  5. +7 −0 test.js
18 LICENSE
@@ -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 README.mkd
@@ -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 package.json
@@ -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 pandoc.js
@@ -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 test.js
@@ -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.
Something went wrong with that request. Please try again.