improve bin/marked, slice off trailing line feeds from code

This commit is contained in:
Christopher Jeffrey 2011-12-04 21:47:31 -06:00
parent b702e91a10
commit c8f26acd12
2 changed files with 6 additions and 3 deletions

View File

@ -10,6 +10,7 @@ var fs = require('fs')
, marked = require('../');
var usage = function() {
console.log('marked - a markdown parser');
console.log('');
console.log('Usage:');
console.log(' marked [-oih] [input]');
@ -82,12 +83,11 @@ var main = function(argv) {
}
}
if (!input) {
if (!input && files.length !== 1) {
input = files.pop();
}
// should maybe detect tty for a repl: tty.isatty(0)
if (fs.statSync(input).ino === fs.statSync(__filename).ino) {
if (files.length === 1) {
var stdin = process.openStdin()
, buff = [];

View File

@ -412,6 +412,9 @@ var tok = function() {
+ '>';
}
case 'code': {
if (token.text[token.text.length-1] === '\n') {
token.text = token.text.slice(0, -1);
}
return '<pre><code>'
+ escape(token.text, true)
+ '</code></pre>';