Giter VIP home page Giter VIP logo

ansi-html-stream's Introduction

ansi-html-stream Build Status Codeship Status for hughsk/ansi-html-stream

A through-stream that converts terminal output to HTML.

Installation

$ npm install ansi-html-stream

Or, if you want to install the CLI tool:

$ [sudo] npm install -g ansi-html-stream

Usage

Take this example to pipe a log of NPM's install command to an HTML file:

$ npm install browserify --color always 2&>1 | ansi-html > browserify.html

And an equivalent from Node:

var spawn = require('child_process').spawn
  , ansi = require('ansi-html-stream')
  , fs = require('fs')

var npm = spawn('npm', ['install', 'browserify', '--color', 'always'], {
    cwd: process.cwd()
})

var stream = ansi({ chunked: false })
  , file = fs.createWriteStream('browserify.html', 'utf8')

npm.stdout.pipe(stream)
npm.stderr.pipe(stream)

stream.pipe(file, { end: false })

stream.once('end', function() {
  file.end('</pre>\n')
})

file.write('<pre>\n');

There are a few options you can pass to the stream too:

  • classes: Use classes instead of inline styles for formatting.
  • theme: Override the styling for particular ANSI codes. See colors.js for two examples.
  • chunked: Ensure that each chunk's elements are self-contained - closes any open <span>s at the end and reopens them on the next chunk. Defaults to false.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.