cardinal

WebJar for cardinal

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

cardinal
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

cardinal
WebJar for cardinal
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/thlorenz/cardinal

Download cardinal

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/cardinal/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>cardinal</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/cardinal/
implementation 'org.webjars.npm:cardinal:1.0.0'
// https://jarcasting.com/artifacts/org.webjars.npm/cardinal/
implementation ("org.webjars.npm:cardinal:1.0.0")
'org.webjars.npm:cardinal:jar:1.0.0'
<dependency org="org.webjars.npm" name="cardinal" rev="1.0.0">
  <artifact name="cardinal" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='cardinal', version='1.0.0')
)
libraryDependencies += "org.webjars.npm" % "cardinal" % "1.0.0"
[org.webjars.npm/cardinal "1.0.0"]

Dependencies

compile (2)

Group / Artifact Type Version
org.webjars.npm : ansicolors jar [0.2.1,0.3)
org.webjars.npm : redeyed jar [1.0.0,1.1)

Project Modules

There are no modules declared in this project.

cardinal Build Status

become a patron

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
  • jsx {Boolean} if true JSX syntax is supported, otherwise cardinal will raise an error when encountering JSX (default: false)

Note The json option is obsoleted and not necessary anymore as cardinal properly understands both JSON and JavaScript.

Examples (browse)

Versions

Version
1.0.0
0.4.4