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

cli-md

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cli-md - npm Package Compare versions

Comparing version 0.1.0 to 1.0.0

3

cli.js
#!/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()))
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

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