Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

msee

Package Overview
Dependencies
Maintainers
1
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 0.1.0 to 0.1.1

Help.md

2

lib/cli.js

@@ -6,3 +6,3 @@ var msee = require('./msee');

function showHelp() {
var helpFile = path.resolve(__dirname, '../README.md');
var helpFile = path.resolve(__dirname, '../Help.md');
var helpText = msee.parseFile(helpFile);

@@ -9,0 +9,0 @@

@@ -8,7 +8,17 @@ var chalk = require('chalk');

"code": chalk.yellow,
"blockquote": chalk.blue
"blockquote": chalk.blue,
"bold": chalk.bold,
"link": chalk.blue,
"strong": chalk.bold,
"em": chalk.italic,
"del": chalk.strikethrough,
"paragraph": null
}
function color(text, type) {
var colorBrush = colorBrushes[type] || chalk.stripColor;
var colorBrush = colorBrushes[type];
if (colorBrush === null)
return text;
if (!colorBrush)
colorBrush = chalk.stripColor;
return colorBrush(text);

@@ -15,0 +25,0 @@ }

var fs = require('fs');
var path = require('path');
var marked = require('marked');
var eighty = require('eighty');
var cardinal = require('cardinal');
var xtend = require('xtend');
var color = require('./color');
var defaultOptions = {
collapseNewlines: true,
space: '',
hrStart: '',
hrEnd: '',
headingStart: '\n',
headingEnd: '\n\n',
headingIndentChar: '#',
codeStart: '\n',
codeEnd: '\n\n',
codePad: ' ',
blockquoteStart: '\n',
blockquoteEnd: '\n\n',
blockquoteColor: 'blockquote',
blockquotePad: ' > ',
blockquotePadColor: 'syntax',
listStart: '\n',
listEnd: '\n',
listItemStart: '',
listItemEnd: '\n',
listItemColor: 'ul',
listItemPad: ' * ',
listItemPadColor: 'syntax',
paragraphStart: '',
paragraphEnd: '\n'
};
var tokens;
var inline;
var token;
var blockDepth = 0;
function processToken() {
function processInline(src, options) {
var out = '';
var cap;
function outLink (title, href) {
out += '[' + color(title, 'strong') + '](' + color(href, 'link') + ')';
}
while (src) {
// escape
if (cap = inline.rules.escape.exec(src)) {
src = src.substring(cap[0].length);
out += cap[1];
continue;
}
// code
if (cap = inline.rules.code.exec(src)) {
src = src.substring(cap[0].length);
out += color(cap[2], 'code');
continue;
}
// autolink
if (cap = inline.rules.autolink.exec(src)) {
src = src.substring(cap[0].length);
out += color(cap[0], 'link');
continue;
}
// url (gfm)
if (cap = inline.rules.url.exec(src)) {
src = src.substring(cap[0].length);
outLink(cap[1], cap[1]);
continue;
}
// tag
if (cap = inline.rules.tag.exec(src)) {
src = src.substring(cap[0].length);
out += cap[0];
continue;
}
// link
if (cap = inline.rules.link.exec(src)) {
src = src.substring(cap[0].length);
outLink(cap[1], cap[2]);
continue;
}
// reflink, nolink
if ((cap = inline.rules.reflink.exec(src))
|| (cap = inline.rules.nolink.exec(src))) {
src = src.substring(cap[0].length);
out += cap[0];
continue;
}
// strong
if (cap = inline.rules.strong.exec(src)) {
src = src.substring(cap[0].length);
out += color(processInline(cap[2] || cap[1]), 'strong');
continue;
}
// em
if (cap = inline.rules.em.exec(src)) {
src = src.substring(cap[0].length);
out += color(processInline(cap[2] || cap[1]), 'em');
continue;
}
// br
if (cap = inline.rules.br.exec(src)) {
src = src.substring(cap[0].length);
out += '\n';
continue;
}
// del (gfm)
if (cap = inline.rules.del.exec(src)) {
src = src.substring(cap[0].length);
out += color(processInline(cap[1]), 'del');
continue;
}
// text
if (cap = inline.rules.text.exec(src)) {
src = src.substring(cap[0].length);
out += cap[0];
continue;
}
if (src) {
throw new Error('Infinite loop on byte: ' + src.charCodeAt(0));
}
}
return out;
}
function processToken(options) {
var type = token.type;
var text = token.text;
var content;
switch (type) {
case 'space': {
return '';
return options.space;
}
case 'hr': {
return color(eighty.hr(), type) + '\n';
var hrStr = new Array(80).join('-') + '\n';
return options.hrStart + color(hrStr, type) + options.hrEnd;
}
case 'heading': {
var syntaxFlag = color(
Array(token.depth + 1).join('#'),
"syntax"
Array(token.depth + 1).join(options.headingIndentChar),
'syntax'
);
var content = color(text, type);
text = processInline(text);
content = color(text, type);
return '\n' + syntaxFlag + ' ' + content + '\n\n';
return options.headingStart + syntaxFlag + ' ' + content + options.headingEnd;
}
case 'code': {
var content = '';
content = '';

@@ -43,6 +176,6 @@ try {

content = blockFormat(content, {
pad_str: ' '
pad_str: options.codePad
});
return '\n' + content + '\n\n';
return options.codeStart + content + options.codeEnd;
}

@@ -53,28 +186,28 @@ case 'table': {

case 'blockquote_start': {
var content = '';
content = '';
blockDepth++;
while (next().type !== 'blockquote_end') {
content += processToken();
content += processToken(options);
}
content = blockFormat(content, {
block_color: 'blockquote',
pad_str: ' > ',
pad_color: 'syntax'
block_color: options.blockquoteColor,
pad_str: options.blockquotePad,
pad_color: options.blockquotePadColor
});
blockDepth--;
return '\n' + content + '\n\n';
return options.blockquoteStart + content + options.blockquoteEnd;
}
case 'list_start': {
var content = '';
content = '';
while (next().type !== 'list_end') {
content += processToken();
content += processToken(options);
}
return '\n' + content + '\n';
return options.listStart + content + options.listEnd;
}
case 'list_item_start': {
var content = '';
content = '';

@@ -85,11 +218,11 @@ while (next().type !== 'list_item_end') {

} else {
content += processToken();
content += processToken(options);
}
}
content = blockFormat(content, {
block_color: 'ul',
pad_str: ' * ',
pad_color: 'syntax'
block_color: options.listItemColor,
pad_str: options.listItemPad,
pad_color: options.listItemPadColor
});
return content + '\n';
return options.listItemStart + content + options.listItemEnd;
}

@@ -100,3 +233,4 @@ case 'paragraph': {

}
return color(text, type) + '\n';
text = processInline(text);
return options.paragraphStart + color(text, type) + options.paragraphEnd;
}

@@ -137,4 +271,6 @@ default: {

exports.parse = function(text) {
exports.parse = function(text, options) {
tokens = marked.lexer(text);
inline = new marked.InlineLexer(tokens.links);
options = xtend(defaultOptions, options);

@@ -145,6 +281,9 @@ var outputArr = [];

while (next()) {
outputArr.push(processToken());
outputArr.push(processToken(options));
}
output = outputArr.join('').replace(/\n\n\n/g, '\n\n');
if (options.collapseNewlines) {
output = outputArr.join('').replace(/\n\n\n/g, '\n\n');
}
tokens = null;

@@ -156,3 +295,3 @@ token = null;

exports.parseFile = function(file) {
exports.parseFile = function(file, options) {
var filePath = path.resolve(__dirname, file);

@@ -163,3 +302,3 @@ var ret = '';

var text = fs.readFileSync(filePath).toString();
ret = exports.parse(text);
ret = exports.parse(text, options);
}

@@ -166,0 +305,0 @@ catch (e) {

{
"name": "msee",
"version": "0.1.0",
"description": "Msee is a command-line tool to read markdown file, and it's a library help your command-line software to output readable markdown content.",
"version": "0.1.1",
"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.",
"main": "./lib/msee.js",

@@ -12,7 +12,7 @@ "bin": "./bin/msee",

"dependencies": {
"chalk": "~0.3.0",
"cardinal": "0.3.2",
"eighty": "0.0.1",
"marked": "0.2.8",
"nopt": "2.1.1"
"chalk": "~0.4.0",
"cardinal": "~0.4.3",
"marked": "~0.3.0",
"nopt": "~2.1.1",
"xtend": "~2.1.1"
},

@@ -29,3 +29,3 @@ "keywords": [

"author": "Firede <firede@firede.us>",
"license": "BSD",
"license": "MIT",
"bugs": {

@@ -32,0 +32,0 @@ "url": "https://github.com/firede/msee/issues"

@@ -1,8 +0,18 @@

Msee
msee
===
*Msee* is a command-line tool to read markdown file.
[![Dependencies Status](https://david-dm.org/firede/msee.png)](https://david-dm.org/firede/msee)
*msee* is a command-line tool to read markdown file.
And it's a library help your command-line software to output readable markdown content.
## Screenshot
![msee](https://f.cloud.github.com/assets/157338/1808778/175a83aa-6d77-11e3-8cf7-7c756bab34f8.png)
## Installation
$ npm install -g msee
## Usage

@@ -13,6 +23,2 @@

## Screenshot
![Msee](./screenshot.png)
## API

@@ -29,1 +35,13 @@

```
## Contributors
https://github.com/firede/msee/graphs/contributors
## License
MIT &copy; [Firede](https://github.com/firede)
===
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/firede/msee/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc