Permalink
Browse files

Merge remote branch 'upstream/master'

Conflicts:
	bin/ronn.js
  • Loading branch information...
2 parents 1a742ce + 6571a27 commit 017055207e33af17a4b53ec2bb7098ee183a2c02 @trentm committed Mar 21, 2011
Showing with 66 additions and 46 deletions.
  1. +8 −1 CHANGES
  2. +2 −0 README.md
  3. +55 −44 bin/ronn.js
  4. +1 −1 package.json
View
@@ -1,10 +1,17 @@
Ronnjs Changes and Release Notes
==============================
+Version 0.3.7
+------------------------------
+
+
+
Version 0.3.6
------------------------------
-* Minor changes the README
+* Minor changes in the README
+* Operate over stdio by default, leaving 'file' as a non-required argument.
+ (Thanks to TJ Holowaychuk)
Version 0.3.5
View
@@ -14,6 +14,8 @@ This outputs doc.roff from a markdown file :
Command-line options are listed with --help
+When file argument is omitted, ronn.js reads standard input.
+
## How it works ?
View
@@ -1,12 +1,12 @@
#!/usr/bin/env node
-var RONN_VERSION = "0.3.6";
+var RONN_VERSION = "0.3.7";
var sys = require('sys');
var fs = require('fs');
var path = require('path');
var opts = require('opts');
-var ronn = require(__dirname + '/../lib/ronn');
+var Ronn = require(__dirname + '/../lib/ronn').Ronn;
var options = [
{ short : 'V'
@@ -48,56 +48,67 @@ var options = [
];
var arguments = [
{ name : 'file'
- , required : true
+ , required : false
, description: 'A ronn file'
}
];
opts.parse(options, arguments, true);
-var fPath = opts.arg('file');
-
-var fBase = path.join(path.dirname(fPath), path.basename(fPath, path.extname(fPath)));
+var buf = '';
+if (opts.arg('file')) {
+ var fPath = opts.arg('file');
+ var fBase = path.join(path.dirname(fPath), path.basename(fPath, path.extname(fPath)));
+ buf = fs.readFileSync(fPath, 'utf8');
+ render(buf);
+} else {
+ process.stdin
+ .on('data', function(chunk){ buf += chunk; })
+ .on('end', function(){
+ render(buf)
+ }).resume();
+}
-var fTxt = fs.readFileSync(fPath, 'utf8');
-var ronn = new ronn.Ronn(fTxt, opts.get("version"), opts.get("manual"), opts.get("date"));
+function render(pTxt) {
+ var ronn = new Ronn(pTxt, opts.get("version"), opts.get("manual"), opts.get("date"));
-if (opts.get("man") && !opts.get("build")) {
- var spawn = require('child_process').spawn;
- var man = spawn('man', ['--warnings', '-E UTF-8', '-l', '-'], {"LANG":"C"});
- man.stdout.addListener('data', function (data) {
- sys.puts(data);
- });
- man.stderr.addListener('data', function (data) {
- sys.puts(data);
- });
- man.addListener('exit', function() {
- process.exit(0);
- });
- man.stdin.write(ronn.roff(), 'utf8');
- man.stdin.end();
-} else {
- var fRoff = null;
- var fHtml = null;
- var fFrag = null;
- if (!opts.get("html") && !opts.get("fragment")) fRoff = ronn.roff();
- else {
- if (opts.get("roff")) fRoff = ronn.roff();
- if (opts.get("html")) fHtml = ronn.html();
- if (opts.get("fragment")) {
- if (opts.get("html")) {
- sys.debug("Can't use both --fragment and --html");
- process.exit(-1);
+ if (opts.get("man") && !opts.get("build")) {
+ var spawn = require('child_process').spawn;
+ var man = spawn('man', ['--warnings', '-E UTF-8', '-l', '-'], {"LANG":"C"});
+ man.stdout.addListener('data', function (data) {
+ sys.puts(data);
+ });
+ man.stderr.addListener('data', function (data) {
+ sys.puts(data);
+ });
+ man.addListener('exit', function() {
+ process.exit(0);
+ });
+ man.stdin.write(ronn.roff(), 'utf8');
+ man.stdin.end();
+ } else {
+ var fRoff = null;
+ var fHtml = null;
+ var fFrag = null;
+ if (!opts.get("html") && !opts.get("fragment")) fRoff = ronn.roff();
+ else {
+ if (opts.get("roff")) fRoff = ronn.roff();
+ if (opts.get("html")) fHtml = ronn.html();
+ if (opts.get("fragment")) {
+ if (opts.get("html")) {
+ sys.debug("Can't use both --fragment and --html");
+ process.exit(-1);
+ }
+ fFrag = ronn.fragment();
}
- fFrag = ronn.fragment();
}
- }
- if (opts.get("build")) {
- if (fRoff) fs.writeFileSync(fBase + ".roff", fRoff, 'utf8');
- if (fHtml) fs.writeFileSync(fBase + ".html", fHtml, 'utf8');
- if (fFrag) fs.writeFileSync(fBase + ".fragment", fFrag, 'utf8');
- } else {
- if (fRoff) process.stdout.write(fRoff);
- if (fHtml) process.stdout.write(fHtml);
- if (fFrag) process.stdout.write(fFrag);
+ if (opts.get("build")) {
+ if (fRoff) fs.writeFileSync(fBase + ".roff", fRoff, 'utf8');
+ if (fHtml) fs.writeFileSync(fBase + ".html", fHtml, 'utf8');
+ if (fFrag) fs.writeFileSync(fBase + ".fragment", fFrag, 'utf8');
+ } else {
+ if (fRoff) process.stdout.write(fRoff);
+ if (fHtml) process.stdout.write(fHtml);
+ if (fFrag) process.stdout.write(fFrag);
+ }
}
}
View
@@ -1,6 +1,6 @@
{
"name" : "ronn",
- "version" : "0.3.6",
+ "version" : "0.3.7",
"description" : "markdown to roff and html converter",
"keywords" : [ "markdown", "roff", "man", "documentation" ],
"main" : "lib/ronn",

0 comments on commit 0170552

Please sign in to comment.