Permalink
Browse files

Added executable markdown.

  • Loading branch information...
1 parent 861ef73 commit 3ed60aa3f15ea9956671e56f7aa6d292110c972b @kriskowal kriskowal committed Aug 3, 2009
Showing with 19 additions and 0 deletions.
  1. +2 −0 bin/markdown
  2. +17 −0 lib/markdown.js
View
@@ -0,0 +1,2 @@
+#!/usr/bin/env narwhal
+require("markdown").main(system);
View
@@ -1288,3 +1288,20 @@ exports.encode = function (src) {
return exports.makeHtml(src);
};
+exports.main = function (system) {
+ var command = system.args.shift();
+ if (!system.args.length) {
+ system.stdout.write(exports.markdown(system.stdin.read())).flush();
+ } else {
+ var arg;
+ while (arg = system.args.shift()) {
+ var out = system.fs.basename(arg, '.md') + '.html';
+ print(out);
+ system.fs.write(out, exports.markdown(system.fs.read(arg)));
+ }
+ }
+};
+
+if (require.main == module.id)
+ exports.main(system);
+

0 comments on commit 3ed60aa

Please sign in to comment.