JSPM

  • Created
  • Published
  • Downloads 3124728
  • Score
    100M100P100Q205385F
  • License MIT

A custom render for marked to output to the Terminal

Package Exports

  • marked-terminal

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (marked-terminal) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

marked-terminal

Custom Renderer for marked allowing for printing Markdown to the Terminal. Supports pretty tables, syntax highlighting for javascript, and overriding all colors and styles.

Could for instance be used to print usage information.

Install

npm install marked marked-terminal

Example

var marked = require('marked');
var TerminalRenderer = require('../');

marked.setOptions({
  // Define custom renderer
  renderer: new TerminalRenderer()
});

// Show the parsed data
console.log(marked('# Hello \n This is **markdown** printed in the `terminal`'));

This will produce the following:

Screenshot of marked-terminal

Syntax Highlighting

Also have support for syntax highlighting using cardinal. You can override highlight defaults by passing in settings as the second argument for TerminalRenderer, or you can create a .cardinalrc as defined in the cardinal README.

Example source

  ``js
  var foo = function(bar) {
    console.log(bar);
  };
  foo('Hello');
  ``

(But with proper syntax. Using "``" to avoid Github markdown)

// Show the parsed data
console.log(marked(exampleSource));

This will produce the following:

Screenshot of marked-terminal

API

Constructur: new TerminalRenderer([options][, highlightOptions])

options

Optional Used to override default styling.

Default values are:

var defaultOptions = {
  code: chalk.yellow,
  blockquote: chalk.gray.italic,
  html: chalk.gray,
  heading: chalk.green.bold,
  firstHeading: chalk.magenta.underline.bold,
  hr: chalk.reset,
  listitem: chalk.reset,
  table: chalk.reset,
  paragraph: chalk.reset,
  strong: chalk.bold,
  em: chalk.italic,
  codespan: chalk.yellow,
  del: chalk.dim.gray.strikethrough,
  link: chalk.blue,
  href: chalk.blue.underline,

  // Wheter or not to undo marked escaping
  // of enitities (" -> " etc)
  unescape: true
};

Example of overriding defaults

marked.setOptions({
  renderer: new TerminalRenderer({
    codespan: chalk.underline.magenta,
  })
});

highlightOptions

Options passed into cardinal. See readme there to see what options to pass.

See more examples