Permalink
Browse files

added md2html

  • Loading branch information...
coolaj86 committed Oct 20, 2011
1 parent 8b3cc2f commit d9235f50e2bbbf73e20780b9bd77acd678ee58e1
Showing with 49 additions and 0 deletions.
  1. +14 −0 README.markdown
  2. +32 −0 bin/md2html.js
  3. +3 −0 package.json
View
@@ -23,6 +23,16 @@ process should actually look, which include:
[JsonML]: http://jsonml.org/ "JSON Markup Language"
+## Installation
+
+Just the `markdown` library:
+
+ npm install markdown
+
+Also install `md2html` to `/usr/local/bin` (or wherever)
+
+ npm install -g markdown
+
## Usage
The simple way to use it with CommonJS is:
@@ -39,6 +49,10 @@ and hosted somewhere for nicer browsing.
We're yet to try it out in a browser, though it's high up on our list of
things to sort out for this project.
+### md2html
+
+ md2html /path/to/doc.md > /path/to/doc.html
+
[lib/markdown.js]: http://github.com/evilstreak/markdown-js/blob/master/lib/markdown.js
## Intermediate Representation
View
@@ -0,0 +1,32 @@
+#!/usr/bin/env node
+(function () {
+ "use strict";
+
+ var fs = require('fs')
+ , markdown = require('markdown').markdown
+ , fullpath = process.argv[2]
+ ;
+
+ function convert(err, data) {
+ var md
+ , html
+ ;
+
+ if (err) {
+ throw err;
+ }
+
+ md = data.toString('utf8');
+ html = markdown.toHTML(md);
+ console.log(html);
+ }
+
+ if (!fullpath) {
+ console.error('try: ', process.argv[1].split('/').pop(), '/path/to/doc.md');
+ return;
+ }
+
+ console.log(markdown);
+
+ fs.readFile(fullpath, convert);
+}())
View
@@ -45,5 +45,8 @@
"name" : "markdown",
"main" : "./lib/index.js"
}
+ },
+ "bin": {
+ "md2html": "./bin/md2html.js"
}
}

0 comments on commit d9235f5

Please sign in to comment.