Skip to content
Browse files

Merge pull request #30 from coolaj86/md2html

add md2html binary
  • Loading branch information...
2 parents 3e27b67 + d9235f5 commit 38d52e89ba8510fe5ad6e0c7c0494de12a0dde6e @ashb ashb committed Oct 20, 2011
Showing with 49 additions and 0 deletions.
  1. +14 −0 README.markdown
  2. +32 −0 bin/md2html.js
  3. +3 −0 package.json
View
14 README.markdown
@@ -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
32 bin/md2html.js
@@ -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
3 package.json
@@ -45,5 +45,8 @@
"name" : "markdown",
"main" : "./lib/index.js"
}
+ },
+ "bin": {
+ "md2html": "./bin/md2html.js"
}
}

0 comments on commit 38d52e8

Please sign in to comment.
Something went wrong with that request. Please try again.