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

cli-highlight

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cli-highlight

Syntax highlighting in your terminal

  • 2.1.11
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.7M
decreased by-4.88%
Maintainers
1
Weekly downloads
 
Created

What is cli-highlight?

The cli-highlight npm package is a syntax highlighter for the command line. It takes code as input and outputs it with syntax highlighting, making it easier to read and understand. It supports a wide range of programming languages and can be used both as a command-line tool and as a library in Node.js applications.

What are cli-highlight's main functionalities?

Syntax highlighting in the terminal

This feature allows you to highlight syntax of code snippets directly in the terminal. The code sample demonstrates how to use the highlight function from the cli-highlight package to syntax highlight a JavaScript code snippet.

const highlight = require('cli-highlight').highlight;
console.log(highlight('const x = 1;', {language: 'javascript', theme: 'default'}));

Highlight code from a file

This feature allows you to read code from a file and output it with syntax highlighting in the terminal. The code sample shows how to read a JavaScript file and use the highlight function to apply syntax highlighting.

const highlight = require('cli-highlight').highlight;
const fs = require('fs');

fs.readFile('example.js', 'utf8', (err, code) => {
  if (err) throw err;
  console.log(highlight(code, {language: 'javascript', theme: 'default'}));
});

Use as a command-line tool

cli-highlight can also be used as a standalone command-line tool. This code sample demonstrates how to use cli-highlight to highlight a JavaScript file named 'example.js' using the default theme.

highlight -l javascript -t default example.js

Other packages similar to cli-highlight

Keywords

FAQs

Package last updated on 28 Mar 2021

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