Skip to content

Commit

Permalink
improve bin/marked, slice off trailing line feeds from code
Browse files Browse the repository at this point in the history
  • Loading branch information
chjj committed Dec 5, 2011
1 parent b702e91 commit c8f26ac
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions bin/marked
Original file line number Diff line number Diff line change
Expand Up @@ -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]');
Expand Down Expand Up @@ -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 = [];

Expand Down
3 changes: 3 additions & 0 deletions lib/marked.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>';
Expand Down

0 comments on commit c8f26ac

Please sign in to comment.