1.0.0 • Published 9 months ago
@kessler/ansi-html-stream v1.0.0
ansi-html-stream

A through-stream that converts terminal output to HTML.
this is a fork
of ansi-html-stream module, made by the wonderful Open Source author @hughsk. all credit goes to him.
changes:
- mocha version was updated and tests too.
- the non-functioning module
clonewas replaced with the "native" functionstructuredClone
Installation
$ npm install ansi-html-streamOr, if you want to install the CLI tool:
$ [sudo] npm install -g ansi-html-streamUsage
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.htmlAnd 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. Seecolors.jsfor 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.
1.0.0
9 months ago