Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parse ANSI escape code colors in the browser?

Tags:

javascript

I have a source that has ANSI escape code color attached to the strings it spits out. These strings are being sent to the browser. I want to parse these ANSI escape codes with javascript in the browser so the it looks like it would in a terminal window.

The goal: ANSI strings -> html spans with styling

Is this possible? First I need to know how to parse ANSI strings in JS.

Thanks!!

like image 522
fancy Avatar asked Jun 14 '12 19:06

fancy


2 Answers

https://github.com/mmalecki/ansispan

like image 124
fancy Avatar answered Nov 02 '22 02:11

fancy


It's been done before. A quick Google search finds escapes.js as one example.

like image 4
ephemient Avatar answered Nov 02 '22 02:11

ephemient