🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

msee

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

msee - npm Package Compare versions

Comparing version

to
0.3.3

lib/stream.js

4

Help.md

@@ -10,4 +10,4 @@ msee

msee <file>
msee <file> | less
msee <file> [file...]
msee <file> [file...] | less
cat <file> | msee

@@ -14,0 +14,0 @@

@@ -1,14 +0,5 @@

var msee = require('./msee');
var nopt = require('nopt');
var path = require('path');
var tty = require('tty');
function showHelp() {
var helpFile = path.resolve(__dirname, '../Help.md');
var helpText = msee.parseFile(helpFile);
console.log(helpText);
}
exports.main = function() {
exports.main = function(args, inpipe) {
var opts = nopt(

@@ -21,35 +12,34 @@ {

},
process.argv,
2
args,
0
);
if (opts.help) {
showHelp();
var files = opts.argv.remain;
if (files.length === 0 && inpipe) {
return inpipe.pipe(require('./stream')())
}
else {
var files = opts.argv.remain;
if (files.length > 0) {
try {
var file = path.resolve(process.cwd(), files[0]);
var text = msee.parseFile(file);
process.stdout.write(text);
}
catch (e) {
console.error(e.message);
}
}
else if (!tty.isatty()) {
var text = '';
process.stdin.on('data', function(chunk) {
text += chunk;
});
process.stdin.on('end', function() {
var out = msee.parse(text);
process.stdout.write(out);
});
}
else {
showHelp();
}
var streamFile = require('./streamFile')
if (files.length === 0 || opts.help) {
files = [path.resolve(__dirname, '../Help.md')]
}
// We use combined-stream-wait-for-it because its the
// same library that is used by workshopper-adventure (a prominent user
// of msee) with this dependency we can ensure a shorter download
// time of workshoppers.
var combinedStream = require('combined-stream-wait-for-it').create()
files
.map(function (file) {
return path.resolve(process.cwd(), file)
})
.forEach(function (file) {
combinedStream.append(streamFile(file))
})
combinedStream.resume()
return combinedStream
}

@@ -12,2 +12,3 @@ var fs = require('fs');

var os = require('os');
var entities = require('entities');

@@ -42,2 +43,3 @@ var defaultOptions = {

listItemPadColor: 'syntax',
orderedListItemPadTemplate: ' x. ',
paragraphStart: '',

@@ -56,2 +58,4 @@ paragraphEnd: '\n\n',

var blockDepth = 0;
var ordinal;
var orderedList = false;

@@ -63,3 +67,7 @@ function processInline(src, options) {

function outLink (title, href) {
out += '[' + color(title, 'strong') + '](' + color(href, 'link') + ')';
if (title) {
out += '[' + color(title, 'strong') + '](' + color(href, 'link') + ')';
} else {
out += '(' + color(href, 'link') + ')';
}
}

@@ -92,3 +100,3 @@

src = src.substring(cap[0].length);
outLink(cap[1], cap[1]);
outLink(null, cap[1]);
continue;

@@ -172,2 +180,6 @@ }

if (text && type != 'code') {
text = entities.decodeHTML(text);
}
switch (type) {

@@ -236,2 +248,4 @@ case 'space': {

content = '';
orderedList = token.ordered;
ordinal = 1;

@@ -244,2 +258,3 @@ while (next().type !== 'list_end') {

}
case 'loose_item_start':
case 'list_item_start': {

@@ -255,2 +270,11 @@ content = '';

}
var pad = options.listItemPad;
if (orderedList) {
var first = options.orderedListItemPadTemplate.replace('x', String(ordinal));
var regular = ' '.repeat(first.length);
pad = { first: first, regular: regular };
++ordinal;
}
content = blockFormat(

@@ -260,3 +284,3 @@ processInline(content),

block_color: options.listItemColor,
pad: options.listItemPad,
pad: pad,
pad_color: options.listItemPadColor,

@@ -266,2 +290,3 @@ width: options.width

);
return options.listItemStart + content + options.listItemEnd;

@@ -268,0 +293,0 @@ }

{
"name": "msee",
"version": "0.3.2",
"version": "0.3.3",
"description": "Msee is a command-line tool to read Markdown file in your terminal, and it's a library help your command-line software to output readable markdown content.",

@@ -19,2 +19,4 @@ "main": "./lib/msee.js",

"chalk": "^1.1.1",
"combined-stream-wait-for-it": "^1.1.0",
"entities": "^1.1.1",
"marked": "^0.3.5",

@@ -24,2 +26,3 @@ "nopt": "^3.0.4",

"text-table": "^0.2.0",
"through2": "^2.0.3",
"wcstring": "^2.1.0",

@@ -46,4 +49,5 @@ "xtend": "^4.0.0"

"devDependencies": {
"stream-to-string": "^1.1.0",
"tap": "^5.7.1"
}
}
- hi
- ho
- hu
- hum

@@ -6,9 +6,14 @@ const test = require('tap').test

const os = require('os')
const cli = require('../lib/cli')
const streamToString = require('stream-to-string')
function fixture (fileName) {
return path.join(__dirname, 'fixtures', fileName)
}
test('default general test', function (t) {
var platform = os.platform() === 'linux' ? '.linux' : ''
var pth = 'general' + platform + '.out'
var out = fs.readFileSync(path.join(__dirname, 'fixtures', pth), 'utf8')
var out = fs.readFileSync(fixture('general' + platform + '.out'), 'utf8')
t.equal(
msee.parseFile(path.join(__dirname, 'fixtures', 'general.md'), {maxWidth: 80}),
msee.parseFile(fixture('general.md'), {maxWidth: 80}),
out

@@ -18,1 +23,14 @@ )

})
test('multifile test', function (t) {
streamToString(cli.main([
fixture('multifile-first.md'),
fixture('multifile-second.md')
]), function (err, msg) {
var out = fs.readFileSync(fixture('multifile.out'), 'utf8')
t.equal(err, null)
t.equal(msg, out)
t.end()
})
})

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet