mirror of
https://github.com/markedjs/marked
synced 2024-11-23 09:48:17 +00:00
improve bin/marked, slice off trailing line feeds from code
This commit is contained in:
parent
b702e91a10
commit
c8f26acd12
@ -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 = [];
|
||||
|
||||
|
@ -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>';
|
||||
|
Loading…
Reference in New Issue
Block a user