Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/timmarinin/ansi2html

Node.js stream to convert ANSI escape sequences (aka color codes) to HTML
https://github.com/timmarinin/ansi2html

Last synced: 1 day ago
JSON representation

Node.js stream to convert ANSI escape sequences (aka color codes) to HTML

Awesome Lists containing this project

README

        

stream-ansi2html
========

![Dependencies](https://david-dm.org/marinintim/ansi2html.svg)

It is a stream to transform terminal color sequences to html tags.

## Usage
```
var ansi2html = require('stream-ansi2html')

var s = Readable()
s.push('\u001b\[32m;Hello, Github')
s.push(null)

s.pipe(ansi2html()).pipe(process.stdout)
// will output Hello, Github
```

## Options

There is a couple of options to trigger. Pass them as first argument to `ansi2html`

```
var mySuperStream = ansi2html({ style: 'class', prefix: 'mySuperPrefix-' })
s.pipe(mySuperStream).pipe(process.stdout)
// will output Hello, Github
```

`style`: 'inline' | 'class'. Inline is default and will apply styles, well, inline.
Class instead only adds classes to span, you should style them. Classes are named
with this pattern: `prefix-property-value`.

`prefix`: `ansi2html-` | String. Has effect only with `style: 'class'`.

## Why

This module was written to help with @marinintim/webify-workshop