Class: Ansible::Output::Ansi2Html
- Inherits:
-
Object
- Object
- Ansible::Output::Ansi2Html
- Defined in:
- lib/ansible/output.rb
Overview
Converter for strings containing with ANSI escape sequences
Constant Summary collapse
- COLOR =
Hash of colors to convert shell colours to CSS
{ '1' => 'font-weight: bold', '30' => 'color: black', '31' => 'color: red', '32' => 'color: green', '33' => 'color: yellow', '34' => 'color: blue', '35' => 'color: magenta', '36' => 'color: cyan', '37' => 'color: white', '90' => 'color: grey' }
- SUPPORTED_STYLE_PATTERN =
/\e\[([0-1])?[;]?(3[0-7]|90|1)m/
- END_ESCAPE_SEQUENCE_PATTERN =
/\e\[0m/
- UNSUPPORTED_STYLE_PATTERN =
/\e\[[^0]*m/
- IGNORED_OUTPUT =
/./m
- OPEN_SPAN_TAG =
%{<span>}
- CLOSE_SPAN_TAG =
%{</span>}
Instance Method Summary collapse
-
#initialize(line) ⇒ Ansi2Html
constructor
Create StringScanner for string.
-
#to_html(stream) ⇒ String, IO
Generate HTML from string formatted with ANSI escape sequences.
Constructor Details
#initialize(line) ⇒ Ansi2Html
Create StringScanner for string
43 44 45 46 |
# File 'lib/ansible/output.rb', line 43 def initialize(line) # ensure any HTML tag characters are escaped @strscan = StringScanner.new(ERB::Util.h line) end |
Instance Method Details
#to_html(stream) ⇒ String, IO
Generate HTML from string formatted with ANSI escape sequences
50 51 52 53 54 55 56 |
# File 'lib/ansible/output.rb', line 50 def to_html(stream) until @strscan.eos? stream << generate_html end stream end |