Comparing version 0.0.5 to 0.0.6
@@ -27,2 +27,4 @@ #!/usr/bin/env node | ||
function run(options, callback) { | ||
rend.settings = options; | ||
if (typeof callback !== 'function') { | ||
@@ -63,4 +65,4 @@ callback = function(){}; | ||
// Inline | ||
strong: chalk.cyan, | ||
em: chalk.yellow.dim.italic, | ||
strong: chalk.red.bold, | ||
em: chalk.yellow.italic, | ||
codespan: chalk.inverse.dim.bold, | ||
@@ -78,8 +80,8 @@ del: chalk.bgWhite.gray.strikethrough, | ||
headings: [ | ||
chalk.bgBlue.black.bold, | ||
chalk.bgGreen.black.bold, | ||
chalk.bgCyan.black.bold, | ||
chalk.bgMagenta.black.bold, | ||
chalk.bgYellow.black.bold, | ||
chalk.bgRed.black.bold, | ||
chalk.bgBlue.white.bold, | ||
chalk.bgGreen.white.bold, | ||
chalk.bgCyan.white.bold, | ||
chalk.bgMagenta.white.bold, | ||
chalk.bgYellow.white.bold, | ||
chalk.bgRed.white.bold, | ||
], | ||
@@ -95,4 +97,4 @@ hr: chalk.white, | ||
// Inline | ||
strong: chalk.cyan, | ||
em: chalk.yellow.dim.italic, | ||
strong: chalk.red.bold, | ||
em: chalk.green.italic, | ||
codespan: chalk.inverse.dim.bold, | ||
@@ -106,20 +108,20 @@ del: chalk.bgBlack.gray.strikethrough, | ||
if (options.github) { | ||
var url = 'https://github.com/' + options.file + '/raw/master/README.md'; | ||
if (options.github === true) { | ||
console.log('Github flag requires a repo as an argument, e.g. ' + style.codespan(' mdr -g mrchimp/mdr ')); | ||
process.exit(); | ||
} | ||
var url = 'https://github.com/' + options.github + '/raw/' + options.branch + '/' + options.file; | ||
readRemoteFile(url); | ||
} else if (options.bitbucket) { | ||
var url = 'https://bitbucket.org/' + options.file + '/raw/master/README.md'; | ||
if (options.bitbucket === true) { | ||
console.log('Bitbucket flag requires a repo as an argument, e.g. ' + style.codespan(' mdr -b mrchimp/mdr ')); | ||
process.exit(); | ||
} | ||
var url = 'https://bitbucket.org/' + options.bitbucket + '/raw/' + options.branch + '/' + options.file; | ||
readRemoteFile(url); | ||
} else { | ||
// First, try and use given file name | ||
if (!options.file) { | ||
options.file = options.file; | ||
} | ||
// If no file name, default to readme.md | ||
if (!options.file) { | ||
console.log('No filename given. Looking for README.md...'); | ||
options.file = 'README.md'; | ||
} | ||
// If file exists, render it. Else try getting from web | ||
fs.stat(options.file, function (err, stat) { | ||
@@ -252,11 +254,16 @@ if (!err) { | ||
rend.heading = function(text, level) { | ||
var full_text, | ||
output = ''; | ||
var full_text = '', | ||
output = '', | ||
color_level = Math.min(level, 6); // We have limited colors | ||
level = Math.min(level, 6); | ||
if (this.settings.simple_headings) { | ||
full_text += indent; | ||
} else { | ||
full_text += repeat('#', level) + ' '; | ||
} | ||
full_text = indent + text + repeat(' ', window_width - text.length - 4); | ||
full_text += text + repeat(' ', window_width - full_text.length - text.length); | ||
output = style.p('\n\n'); | ||
output += style.headings[level - 1](full_text); | ||
output += style.headings[color_level - 1](full_text); | ||
output += '\n'; | ||
@@ -263,0 +270,0 @@ |
{ | ||
"name": "mdr", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Read markdown files in the terminal in color", | ||
@@ -30,2 +30,3 @@ "main": "lib", | ||
"marked": "~0.3.2", | ||
"rc": "^0.5.0", | ||
"request": "^2.40.0", | ||
@@ -32,0 +33,0 @@ "yargs": "~1.3.1" |
@@ -10,3 +10,3 @@ # mdr # | ||
## Usage ## | ||
## Installation ## | ||
@@ -17,12 +17,30 @@ Install the `mdr` command globally | ||
Then you can do the following... | ||
## Usage ## | ||
mdr [file] [[-g github_repo | -b bitbucket_repo] [-B] | -h | -v] [-i] [-s] | ||
The first parameter should be a file name or url. If not provided, this will default to `README.md`. `github_repo` and `bitbucket_repo` should be in the format `user/rpo` e.g. `mrchimp/mdr`. | ||
Here are some things you can do: | ||
mdr # Show README.md from current directory | ||
mdr foo.md -i # Use dark-on-light style | ||
mdr http://example.com/foo.md # Show foo.md from a the web | ||
mdr mrchimp/mdr -g # Show README.md from Github repo | ||
mdr -g mrchimp/mdr # Show README.md from Github repo | ||
mdr foo.md -g bar/bar # Show foo.md from Bitbucket repo | ||
Do `mdr -h` for more help. | ||
`mdr -h` for more help. | ||
## Config ## | ||
Config files are found and parsed by [rc](https://www.npmjs.org/package/rc). For example put the following content in `$HOME/.mdrrcrc` or `$HOME/.mdr/config`. | ||
{ | ||
"invert": "true" | ||
} | ||
See `rc` docs for more in-depth instructions. | ||
## Notes ## | ||
@@ -29,0 +47,0 @@ |
54
test.md
@@ -22,5 +22,30 @@ | ||
# Emphasis and Strong # | ||
I'm speaking normally here *but this bit has emphasis* because I feel it's important. And **this bit is really strong**, because seriously. Here's some text ***that's strong and emphasised*** and for some reason is colored blue. | ||
# Links # | ||
[This is a link to Github](http://github.com) | ||
[This is another link](http://example.com) | ||
# Code Blocks # | ||
var this_line = 'a block of code'; | ||
this_line.is('also code'); | ||
if (this.renders) { | ||
kettle.fill().turnOn(); | ||
} | ||
# Inline Code # | ||
Here's a paragraph with bits of code like `var foo = (bar * koala);` in it. Inline code `print('woo')` yay. | ||
# Horizontal Rules # | ||
--------------- | ||
# Blockquotes # | ||
> This is a blockquote. The path of the righteous man is beset on all sides by the iniquities of the selfish and the tyranny of evil men. Blessed is he who, in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother's keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy My brothers. And you will know My name is the Lord when I lay My vengeance upon thee. | ||
@@ -78,29 +103,2 @@ | ||
# Horizontal Rules # | ||
--------------- | ||
# Code Blocks # | ||
var this_line = 'a block of code'; | ||
this_line.is('also code'); | ||
if (this.renders) { | ||
kettle.fill().turnOn(); | ||
} | ||
# Inline Code # | ||
Here's a paragraph with bits of code like `var foo = (bar * koala);` in it. Inline code `print('woo')` yay. | ||
# Links # | ||
[This is a link to Github](http://github.com) | ||
[This is another link](http://example.com) | ||
# Emphasis and Strong # | ||
I'm speaking normally here *but this bit has emphasis* because I feel it's important. And **this bit is really strong**, because seriously. | ||
# Image # | ||
@@ -107,0 +105,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17546
301
82
6
+ Addedrc@^0.5.0
+ Addeddeep-extend@0.2.11(transitive)
+ Addedini@1.3.8(transitive)
+ Addedminimist@0.0.10(transitive)
+ Addedrc@0.5.5(transitive)
+ Addedstrip-json-comments@0.1.3(transitive)