Socket
Socket
Sign inDemoInstall

ansi-html

Package Overview
Dependencies
0
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ansi-html

An elegant lib that converts the chalked (ANSI) text to HTML.


Version published
Weekly downloads
3.8M
increased by1.85%
Maintainers
1
Install size
39.9 kB
Created
Weekly downloads
 

Package description

What is ansi-html?

The ansi-html npm package is a utility for converting ANSI escape codes (often used for colorizing text in terminal/console output) into HTML elements. This can be particularly useful when you want to display styled console output on a web page.

What are ansi-html's main functionalities?

Convert ANSI escape codes to HTML

This feature allows you to convert text containing ANSI escape codes for color and style into equivalent HTML with inline styles. The example code demonstrates how to convert a string with ANSI codes for red text into an HTML span element with the color set to red.

const ansiHTML = require('ansi-html');
const text = '\u001b[31mHello World\u001b[39m';
const html = ansiHTML(text);
console.log(html); // '<span style="color:#FF0000;">Hello World</span>'

Other packages similar to ansi-html

Readme

Source

ansi-html NPM version Build Status

An elegant lib that converts the chalked (ANSI) text to HTML.

Coverage

  • All styles of chalk (100%).
  • There are over 150 randomized test cases under test.

Installation

$ npm install ansi-html

Usage

var ansiHTML = require('ansi-html');
var str = ansiHTML('[ANSI_TEXT]');

e.g.:

var chalk = require('chalk');

var str = chalk.bold.red('foo') + ' bar';
console.log('[ANSI]', str)
console.log('[HTML]', ansiHTML(str));

See complete examples under test / examples directory.

Exposed Tags

var openTags = ansiHTML.tags.open;
var closeTags = ansiHTML.tags.close;

Test

$ npm install -l
$ npm test

Keywords

FAQs

Last updated on 15 Dec 2014

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc