shell-color
Javascript parse ANSI escape code and render to HTML, for CommonJS package
Install
npm install --save shell-color
Constructor
Common parameters
const ShellColor = var sc = colorMap: // optional white: '#cccccc' black: '#333333' defaultBackgroundColor: 'white' // optional defaultForegroundColor: 'black' // optional snippetTag: 'span' // optional
Use Worker
var sc = useWorker: true worker: path: 'node_modules/shell-color/dest/worker.js' { ... }
Usage
sc sc sc sc sc
sc.reset()
Create a new stream, before write you must call reset at least once.
sc.write(text)
Push a text to current stream
You can not keep
\n
in final output, becausetag.innerText
convert\n
to<br>
, for example:var span = documentspaninnerText = '123\n\n456'assert
sc.on()
scscsc
ShellColor.strip(text)
var text = '\x1b[30m black \x1b[m\x1b[31m red'var str = sc // ' black red'
ShellColor.toBlockTags(text)
var tags = ShellColortags
ShellColor.toInlineTags(text)
var tags = ShellColortags
ChangeLog
- 1.1.0 Add web worker support
- 2.0.0 Build change to webpack