class BcatAnsi::Ansi

Overview

Converts ANSI color sequences to HTML.

The ANSI module is based on code from the following libraries:

ansi2html.sh: http://github.com/pixelb/scripts/blob/master/scripts/ansi2html.sh

HTML::FromANSI: http://cpansearch.perl.org/src/NUFFIN/HTML-FromANSI-2.03/lib/HTML/FromANSI.pm

Defined in:

bcat_ansi.cr

Constant Summary

BAD_ESC = /\x08+/
DISPLAY_REGEX = /\x1b\[((?:\d{1,3};?)+|)m/
ESC_ONE = "\e"
ESC_TWO = "\b"
MALFORMED = /\x1b\[?[\d;]{0,3}/
STYLES = {"ef0" => "color:#000", "ef1" => "color:#A00", "ef2" => "color:#0A0", "ef3" => "color:#A50", "ef4" => "color:#00A", "ef5" => "color:#A0A", "ef6" => "color:#0AA", "ef7" => "color:#AAA", "ef8" => "color:#555", "ef9" => "color:#F55", "ef10" => "color:#5F5", "ef11" => "color:#FF5", "ef12" => "color:#55F", "ef13" => "color:#F5F", "ef14" => "color:#5FF", "ef15" => "color:#FFF", "eb0" => "background-color:#000", "eb1" => "background-color:#A00", "eb2" => "background-color:#0A0", "eb3" => "background-color:#A50", "eb4" => "background-color:#00A", "eb5" => "background-color:#A0A", "eb6" => "background-color:#0AA", "eb7" => "background-color:#AAA", "eb8" => "background-color:#555", "eb9" => "background-color:#F55", "eb10" => "background-color:#5F5", "eb11" => "background-color:#FF5", "eb12" => "background-color:#55F", "eb13" => "background-color:#F5F", "eb14" => "background-color:#5FF", "eb15" => "background-color:#FFF"}

Linux console palette

XTERM_REGEX = /\x1b\[38;5;\d+m/

Constructors

Instance Method Summary

Constructor Detail

def self.new #

[View source]

Instance Method Detail

def display_code_handler(data) : String | Nil #

[View source]
def escapey(m) : String | Nil #

[View source]
def handle_display(text, string_array) #

[View source]
def handle_xterm(text, string_array) #

[View source]
def is_raw?(text) #

[View source]
def push_style(style) #

[View source]
def push_tag(tag, style : String | Nil = nil) #

[View source]
def push_text(text) #

[View source]
def stringify_stack #

[View source]
def to_html(input : String) #

[View source]
def tokenize(text, string_array) : String | Nil #

[View source]
def xtermy(m) : String | Nil #

[View source]