add man page, refactor cli, change package.json

This commit is contained in:
Christopher Jeffrey 2012-01-27 15:53:57 -06:00
parent 60f0d2b9f2
commit 623f71a6b9
3 changed files with 64 additions and 34 deletions

View File

@ -2,39 +2,30 @@
/**
* Marked CLI
* Copyright (c) 2011, Christopher Jeffrey (MIT License)
* Copyright (c) 2011-2012, Christopher Jeffrey (MIT License)
*/
var fs = require('fs')
, util = require('util')
, marked = require('../');
var usage = function() {
console.log('marked - a markdown parser');
console.log('');
console.log('Usage:');
console.log(' marked [-oih] [input]');
console.log('');
console.log('Options:');
console.log(' -o, --output: Specify output file. If none is');
console.log(' specified, write to stdout.');
console.log(' -i, --input: Specify input file, otherwise use last');
console.log(' argument as input file. If no input');
console.log(' file is specified, read from stdin.');
console.log(' -t, --tokens: Output a token stream instead of html.');
console.log(' -h, --help: Display this message.');
console.log('');
console.log('Examples:');
console.log(' cat in.md | marked > out.html');
console.log(' echo "hello *world*" | marked');
console.log(' marked -o out.html in.md');
console.log(' marked --output="hello world.html" -i in.md');
console.log('');
console.log(' $ marked');
console.log(' > hello __world__\\n^D');
console.log(' <p>hello <strong>world</strong></p>');
console.log('');
process.exit(0);
var help = function() {
var spawn = require('child_process').spawn;
var options = {
cwd: process.cwd(),
env: process.env,
setsid: false,
customFds: [0, 1, 2]
};
var man = spawn('man',
[__dirname + '/../man/marked.1'],
options);
// man.on('exit', function(code) {
// if (code !== 0) console.error('no man page');
// });
};
var main = function(argv) {
@ -49,7 +40,7 @@ var main = function(argv) {
var arg = argv.shift();
arg = arg.split('=');
if (arg.length > 1) {
argv.unshift(arg.sice(1).join('='));
argv.unshift(arg.slice(1).join('='));
}
return arg[0];
};
@ -71,8 +62,7 @@ var main = function(argv) {
break;
case '-h':
case '--help':
usage();
break;
return help();
default:
files.push(arg);
break;

39
man/marked.1 Normal file
View File

@ -0,0 +1,39 @@
.ds q \N'34'
.TH marked 1
.SH NAME
marked \- a javascript markdown parser
.SH SYNOPSIS
.nf
.B marked [\-o output] [\-i input] [\-th]
.fi
.SH DESCRIPTION
.B marked
is a full-featured javascript markdown parser, built for speed. It also includes
multiple GFM features.
.SH OPTIONS
.TP
.BI \-o,\ \-\-output\ [output]
Specify file output. If none is specified, write to stdout.
.TP
.BI \-i,\ \-\-input\ [input]
Specify file input, otherwise use last argument as input file. If no input file
is specified, read from stdin.
.TP
.BI \-t,\ \-\-tokens
Output a token stream instead of html.
.TP
.BI \-h,\ \-\-help
Display help information.
.SH EXAMPLES
.TP
cat in.md | marked > out.html
.TP
echo "hello *world*" | marked
.TP
marked -o out.html in.md
.TP
marked --output="hello world.html" -i in.md
.SH BUGS
Please report any bugs to https://github.com/chjj/marked.
.SH LICENSE
Copyright (c) 2011-2012, Christopher Jeffrey (MIT License)

View File

@ -4,11 +4,12 @@
"author": "Christopher Jeffrey",
"version": "0.1.8",
"main": "./lib/marked.js",
"bin": { "marked": "./bin/marked" },
"bin": "./bin/marked",
"man": "./man/marked.1",
"preferGlobal": false,
"repository": "git://github.com/chjj/marked.git",
"bugs" : {
"url": "http://github.com/chjj/marked/issues"
},
"homepage": "https://github.com/chjj/marked",
"bugs": "http://github.com/chjj/marked/issues",
"keywords": [ "markdown", "markup", "html" ],
"tags": [ "markdown", "markup", "html" ]
}