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

cardinal

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cardinal

Syntax highlights JavaScript code with ANSI colors to be printed to the terminal.

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.8M
decreased by-3.5%
Maintainers
1
Weekly downloads
 
Created

What is cardinal?

The cardinal npm package is a syntax highlighter for JavaScript code. It can be used to display JavaScript code with syntax highlighting in terminal applications. It uses the redeyed package to handle the actual syntax highlighting.

What are cardinal's main functionalities?

Syntax highlighting for JavaScript code

This feature allows you to pass JavaScript code as a string to the `highlight` function, which returns the code with terminal-compatible syntax highlighting.

const cardinal = require('cardinal');
const highlightedCode = cardinal.highlight('const x = 123;');
console.log(highlightedCode);

Syntax highlighting from a file

This feature allows you to read JavaScript code from a file and then use the `highlight` function to display it with syntax highlighting in the terminal.

const cardinal = require('cardinal');
const fs = require('fs');

fs.readFile('example.js', 'utf8', function(err, code) {
  if (err) throw err;
  const highlightedCode = cardinal.highlight(code);
  console.log(highlightedCode);
});

Custom theme support

Cardinal allows you to specify a custom theme for syntax highlighting by passing a theme object as an option to the `highlight` function.

const cardinal = require('cardinal');
const customTheme = require('./myCustomTheme.json');
const highlightedCode = cardinal.highlight('const x = 123;', { theme: customTheme });
console.log(highlightedCode);

Other packages similar to cardinal

Keywords

FAQs

Package last updated on 30 Aug 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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