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('../');
|
, marked = require('../');
|
||||||
|
|
||||||
var usage = function() {
|
var usage = function() {
|
||||||
|
console.log('marked - a markdown parser');
|
||||||
console.log('');
|
console.log('');
|
||||||
console.log('Usage:');
|
console.log('Usage:');
|
||||||
console.log(' marked [-oih] [input]');
|
console.log(' marked [-oih] [input]');
|
||||||
@ -82,12 +83,11 @@ var main = function(argv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!input) {
|
if (!input && files.length !== 1) {
|
||||||
input = files.pop();
|
input = files.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
// should maybe detect tty for a repl: tty.isatty(0)
|
if (files.length === 1) {
|
||||||
if (fs.statSync(input).ino === fs.statSync(__filename).ino) {
|
|
||||||
var stdin = process.openStdin()
|
var stdin = process.openStdin()
|
||||||
, buff = [];
|
, buff = [];
|
||||||
|
|
||||||
|
@ -412,6 +412,9 @@ var tok = function() {
|
|||||||
+ '>';
|
+ '>';
|
||||||
}
|
}
|
||||||
case 'code': {
|
case 'code': {
|
||||||
|
if (token.text[token.text.length-1] === '\n') {
|
||||||
|
token.text = token.text.slice(0, -1);
|
||||||
|
}
|
||||||
return '<pre><code>'
|
return '<pre><code>'
|
||||||
+ escape(token.text, true)
|
+ escape(token.text, true)
|
||||||
+ '</code></pre>';
|
+ '</code></pre>';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user