Giter Site home page Giter Site logo

cardinal's Introduction

cardinal Build Status

NPM

car·di·nal (kärdn-l, kärdnl) - crested thick-billed North American finch having bright red plumage in the male.

screenshot

Features

  • highlights JavaScript code with ANSI colors to improve terminal output
  • theming support, see custom color themes
  • optionally print line numbers
  • API and command line interface (cdl)
  • .cardinalrc config to customize settings
  • supports UNIX pipes

Table of Contents generated with DocToc

Installation

As library

npm install cardinal

As Commandline Tool

[sudo] npm install -g cardinal

Note:

When installed globally, cardinal exposes itself as the cdl command.

Commandline

Highlight a file

cdl <file.js> [options]

options:

  • --nonum: turns off line number printing (relevant if it is turned on inside ~/.cardinalrc

As part of a UNIX pipe

cat file.js | grep console | cdl

Note:

Not all code lines may be parsable JavaScript. In these cases the line is printed to the terminal without highlighting it.

Theme

The default theme will be used for highlighting.

To use a different theme, include a .cardinalrc file in your HOME directory.

This is a JSON file of the following form:

{
  "theme": "hide-semicolons",
  "linenos": true|false
}
  • theme can be the name of any of the built-in themes or the full path to a custom theme anywhere on your computer.
  • linenos toggles line number printing

API

highlight(code[, opts])

  • returns the highlighted version of the passed code ({String}) or throws an error if it was not able to parse it
  • opts (see below)

highlightFileSync(fullPath[, opts])

  • returns the highlighted version of the file whose fullPath ({String}) was passed or throws an error if it was not able to parse it
  • opts (see below)

highlightFile(fullPath[, opts], callback)

  • calls back with the highlighted version of the file whose fullPath ({String}) was passed or with an error if it was not able to parse it
  • opts (see below)
  • callback ({Function}) has the following signature: function (err, highlighted) { .. }

opts

opts is an {Object} with the following properties:

  • theme {Object} is used to optionally override the theme used to highlight
  • linenos {Boolean} if true line numbers are included in the highlighted code
  • firstline {Integer} sets line number of the first line when line numbers are printed
  • json {Boolean} if true highlights JSON in addition to JavaScript (true by default if file extension is .json)

Examples (browse)

Bitdeli Badge

cardinal's People

Contributors

bitdeli-chef avatar firede avatar thlorenz avatar tschaub avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.