Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added executable markdown.

  • Loading branch information...
commit 3ed60aa3f15ea9956671e56f7aa6d292110c972b 1 parent 861ef73
@kriskowal kriskowal authored
Showing with 19 additions and 0 deletions.
  1. +2 −0  bin/markdown
  2. +17 −0 lib/markdown.js
View
2  bin/markdown
@@ -0,0 +1,2 @@
+#!/usr/bin/env narwhal
+require("markdown").main(system);
View
17 lib/markdown.js
@@ -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);
+
Please sign in to comment.
Something went wrong with that request. Please try again.