Comparing version 0.1.0 to 1.0.0
#!/usr/bin/env node | ||
var fs = require('fs') | ||
var concat = require('concat-stream') | ||
var md = require('./index.js') | ||
var md = require('./') | ||
process.stdin.pipe(concat(function (markdown) { | ||
console.log(md(markdown.toString())) | ||
})) |
var md = require('./index.js') | ||
var fs = require('fs') | ||
var example = require('markdown-cheatsheet') | ||
console.log(md(fs.readFileSync('./test.md').toString())) | ||
console.log(md(example())) |
97
index.js
var marked = require('marked') | ||
var TerminalRenderer = require('marked-terminal') | ||
var chalk = require('chalk') | ||
var highlight = require('cardinal').highlight // only JS | ||
var renderer = new marked.Renderer() | ||
var c = { | ||
heading: chalk.bold.cyan, | ||
syntax: chalk.grey, | ||
firstHeading: chalk.bold.cyan, | ||
html: chalk.grey, | ||
strong: chalk.bold.blue, | ||
@@ -15,89 +14,11 @@ em: chalk.italic.magenta, | ||
link: chalk.blue, | ||
href: chalk.gray, | ||
quote: chalk.gray | ||
href: chalk.blue.underline, | ||
blockquote: chalk.gray | ||
} | ||
// Block Level | ||
marked.setOptions({ | ||
renderer: new TerminalRenderer(c) | ||
}) | ||
renderer.heading = function (text, level) { | ||
return c.syntax(Array(level + 1).join('#')) + ' ' + c.heading(text) + '\n\n' | ||
} | ||
module.exports = marked | ||
renderer.hr = function () { | ||
return c.syntax(Array(20).join('-')) + '\n' | ||
} | ||
renderer.paragraph = function (text) { | ||
return text + '\n\n' | ||
} | ||
renderer.list = function (body, ordererd) { | ||
return body + '\n\n' | ||
} | ||
renderer.listitem = function (text, test) { | ||
// TODO: ordering information in list not here | ||
return c.syntax('- ') + text + '\n' | ||
} | ||
renderer.blockquote = function (quote) { | ||
return c.quote(quote) | ||
} | ||
renderer.code = function (code, l) { | ||
// Right now every code is treated like Javascript | ||
if(l == 'js' || l === 'javascript') | ||
code = highlight(code) | ||
return code + '\n\n' | ||
} | ||
renderer.html = function (html) { | ||
return html | ||
} | ||
renderer.table = function (header, body) { | ||
return c.heading(header) + '\n' + body + '\n' | ||
} | ||
renderer.tablerow = function (content) { | ||
return content | ||
} | ||
renderer.tablecell = function (content, flags) { | ||
return content + Array(20-content.length).join(' ') + '|' | ||
} | ||
// Inline Level | ||
renderer.strong = function (text) { | ||
return c.strong(text) | ||
} | ||
renderer.em = function (text) { | ||
return c.em(text) | ||
} | ||
renderer.codespan = function (code) { | ||
return c.codespan(code) | ||
} | ||
renderer.br = function () { | ||
return '\n' | ||
} | ||
renderer.del = function (text) { | ||
return c.syntax('~~') + c.del(text) + c.syntax('~~') | ||
} | ||
renderer.link = function (href, title, text) { | ||
return c.syntax('[') + c.link(text) + c.syntax('](') + c.href(href) + c.syntax(')') | ||
} | ||
renderer.image = function (href, title, text) { | ||
return c.syntax('![') + c.link(text) + c.syntax('](') + c.href(href) + c.syntax(')') | ||
} | ||
marked.setOptions({renderer: renderer}) | ||
module.exports = marked |
{ | ||
"name": "cli-md", | ||
"version": "0.1.0", | ||
"version": "1.0.0", | ||
"description": "Markdown for your terminal", | ||
@@ -10,3 +10,3 @@ "main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "node example.js" | ||
}, | ||
@@ -31,4 +31,8 @@ "repository": { | ||
"concat-stream": "^1.4.6", | ||
"marked": "^0.3.2" | ||
"marked": "^0.3.2", | ||
"marked-terminal": "^1.2.0" | ||
}, | ||
"devDependencies": { | ||
"markdown-cheatsheet": "^1.0.0" | ||
} | ||
} |
# cli-md | ||
[![NPM](https://nodei.co/npm/cli-md.png)](https://nodei.co/npm/cli-md/) | ||
@@ -6,4 +7,4 @@ Transform markdown to terminal colors. Install with `npm install cli-md` | ||
It is inspired by and similar to [msee](https://www.npmjs.org/package/msee), | ||
but the implementation is probably a bit simpler, since I am only overwriting the | ||
`Renderer()` methods of the `marked` module and color it with `chalk`. | ||
but the implementation is using [marked-terminal](https://github.com/mikaelbr/marked-terminal) | ||
as a marked renderer internally. | ||
@@ -10,0 +11,0 @@ ## Usage |
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
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
21
64864
5
1
7
28
+ Addedmarked-terminal@^1.2.0
+ Addedansi-regex@2.1.1(transitive)
+ Addedansi-styles@2.2.1(transitive)
+ Addedcardinal@1.0.0(transitive)
+ Addedchalk@1.1.3(transitive)
+ Addedcli-table@0.3.11(transitive)
+ Addedcolors@1.0.3(transitive)
+ Addedesprima@3.0.0(transitive)
+ Addedhas-ansi@2.0.0(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedlodash.assign@4.2.0(transitive)
+ Addedmarked-terminal@1.7.0(transitive)
+ Addednode-emoji@1.11.0(transitive)
+ Addedredeyed@1.0.1(transitive)
+ Addedstrip-ansi@3.0.1(transitive)
+ Addedsupports-color@2.0.0(transitive)