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

ansi-to-html

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ansi-to-html

Convert ansi escaped text streams to html.

  • 0.7.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is ansi-to-html?

The ansi-to-html package is designed to convert ANSI code (often used for colorizing text in terminal outputs) into HTML. This is particularly useful for displaying styled console output on web pages.

What are ansi-to-html's main functionalities?

Convert ANSI to HTML

This feature allows you to convert ANSI encoded strings to HTML, preserving the color and style formatting for web display. The code sample demonstrates converting a red 'Hello World' string to HTML.

const Convert = require('ansi-to-html');
const convert = new Convert();
const html = convert.toHtml('\x1b[31mHello World\x1b[0m');

Customize color palette

This feature enables customization of the foreground and background colors used in the conversion process. The code sample shows how to set custom foreground and background colors.

const Convert = require('ansi-to-html');
const convert = new Convert({ fg: '#000', bg: '#fff' });
const html = convert.toHtml('your-ansi-string');

Escape HTML

This feature allows you to ensure that the output HTML is properly escaped. This is useful to avoid XSS attacks when displaying user-generated content. The code sample demonstrates enabling HTML escaping.

const Convert = require('ansi-to-html');
const convert = new Convert({ escapeXML: true });
const html = convert.toHtml('your-ansi-string');

Other packages similar to ansi-to-html

Keywords

FAQs

Package last updated on 05 Oct 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