ansi_sgr_to_html 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +15 -0
  2. data/lib/ansi_sgr_to_html.rb +32 -1
  3. metadata +5 -7
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ODcxYmU1NDNiN2FjNjRlM2QxNDNiYjc4NWFmYzU5MGRlZWIyNmE4NA==
5
+ data.tar.gz: !binary |-
6
+ Y2Y0N2JlMDI4NTliNjNlZDBhNGQwNjRhYWIyOWQxNDdhNmVhY2MzMQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ NDcxM2Y0ODk1ODczMmIzNTNjMmIzYjIxMzc4NDNhYjg1ZWU5MjFiNjY3OGJh
10
+ MjFlNWJiMDc0N2EyODQ1NzVkYTg4NTM1OGJkOGFkOTY2ZWJjNTUwYTkyMjlh
11
+ NTliZjc1MDNmYTczNmE2ZmU1NmUzYjk5ZmRkMzRhYjE1MTE3ZDk=
12
+ data.tar.gz: !binary |-
13
+ OGE4MTZiNzM0Y2MxOTgxMjRhYjZhZWE0NjNhNzI0YmMyZTFhMGM0NWYyYzJl
14
+ ODZhZDdkOGVjNjliOGUzNjM1MTBjZGU0ZGNjZGEwMGM2YmE4YWU5N2M1OWZi
15
+ NjMwYjU5YWQ2NWQ2NGYzMGJhMjkxYWQzZWYxMjQ5Y2EwZWI1MDM=
@@ -1,5 +1,20 @@
1
1
  # This is generated by ragel - write me a mail if you are interested in the main source.
2
2
  # Its not included, currently, as I dont want the gem to depend on ragel, for installation.
3
+
4
+ # =ANSI SGR code to HTML converter
5
+ # This gem converts text with ANSI SGR codes to HTML. SGR? Yes, fonts, bold, colors, etc. are ANSI SGR sequences, other ANSI escape codes are not supported.
6
+ # In other words, the only codes that actually make sense to convert are supported, as moving the cursor would not be convertible.
7
+ # ==Overview
8
+ # - supports all standardized SGR codes except ideograms or codes 50-59
9
+ # * this means it supports alternative fonts (user specified)
10
+ # * blink codes supported! Slow and fast!
11
+ # * full support for all SGR color codes, meaning 4bit, 8bit and 24bit colors, for both, foreground and background (most other gems do not, especially not 24bit colors)
12
+ # - supports sequences of SGR codes separated by ';' (some other gems do not)
13
+ # - configurable options by user
14
+ # * custom set all 10 alternative fonts (default: all inherit default font)
15
+ # * is bold only bold, or also bright (default: both)
16
+ # * fully user defineable basic 16 color tables, or pick from preset (default: xterm)
17
+ # - flat output, no nested spans like some other gems (smaller output than most other gems)
3
18
  class ANSI_SGR_To_HTML
4
19
  @@HTML_escapes = {'&'=>'&amp;','"'=>'&quot;','<'=>'&lt;','>'=>'&gt;',"\r"=>"\r","\n"=>"\n"} # newlines controlled by option
5
20
  @@Col_tab_256 = [
@@ -43,7 +58,18 @@ class ANSI_SGR_To_HTML
43
58
  :osx_term => ['000000', 'C23621', '25BC24', 'ADAD27', '492EE1', 'D338D3', '33BBC8', 'CBCCCD', '818383', 'FC391F', '31E722', 'EAEC23', '5833FF', 'F935F8', '14F0F0', 'E9EBEB']
44
59
  }
45
60
  @@CSS_blink_keyframes = '<style>@keyframes term_blink { 0%,50% { opacity: 1; } 51%,100% { opacity: 0; } }</style>'
46
- def initialize(font_styles = [nil]*10, k_21_is_double_underline = true, k_1_is_bold_and_bright = true, k_turn_eol_into_br = false, col_tab_16 = :xterm)
61
+ # Create new instance of converter
62
+ #
63
+ # ======Example
64
+ # >> ANSI_SGR_To_HTML.new(false, :osx_term, ['serif','Courier New']+[nil]*7+['Fraktur'], true, true)
65
+ #
66
+ # ======Arguments
67
+ # [k_turn_eol_into_br] pass true if converter should turn newlines into <br/> on the fly (redundant if output is wrapped in <pre>)
68
+ # [col_tab_16] specify either array with 16 css colors (first 8 are low, last 8 are bright colors), or preset name (:xterm, :osx_term, :cmd, :vga)
69
+ # [font_styles] Array with ten font-names (or nil, to use default), to be used for SGR codes 11-20
70
+ # [k_1_is_bold_and_bright] true renders bold text (SGR code 1) also in bright colors (if color is from basic 16-color table)
71
+ # [k_21_is_double_underline] specify, whether SGR code 21 disables bold text, or enable double-underline
72
+ def initialize(k_turn_eol_into_br = false, col_tab_16 = :xterm, font_styles = [nil]*10, k_1_is_bold_and_bright = true, k_21_is_double_underline = true)
47
73
  @k_21_is_double_underline = k_21_is_double_underline;
48
74
  @k_1_is_bold_and_bright = k_1_is_bold_and_bright;
49
75
  @k_turn_eol_into_br = k_turn_eol_into_br;
@@ -244,6 +270,11 @@ class << self
244
270
  end
245
271
  self.ansi_sgr_to_html_en_main = 43;
246
272
  end
273
+ # Convert string
274
+ #
275
+ # ======Arguments:
276
+ # [i] Input (string at the moment, future versions are planned to accept streams)
277
+ # [o] Output, anything with << to append to (e.g. String, $stdout, etc.) or nil to get a string returned after complete conversion
247
278
  def convert(i, o=nil) # i is string, o can be anything with <<
248
279
  o = '' unless o
249
280
  begin
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ansi_sgr_to_html
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
5
- prerelease:
4
+ version: 1.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Tassilo Philipp
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2015-01-20 00:00:00.000000000 Z
11
+ date: 2015-01-21 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: Converter for complete ANSI SGR codes to HTML. Similar to ansitags gem,
15
14
  but smaller output (no nested spans), faster (converts everything in one pass),
@@ -25,26 +24,25 @@ files:
25
24
  homepage:
26
25
  licenses:
27
26
  - ISC
27
+ metadata: {}
28
28
  post_install_message:
29
29
  rdoc_options: []
30
30
  require_paths:
31
31
  - lib
32
32
  required_ruby_version: !ruby/object:Gem::Requirement
33
- none: false
34
33
  requirements:
35
34
  - - ! '>='
36
35
  - !ruby/object:Gem::Version
37
36
  version: 1.9.1
38
37
  required_rubygems_version: !ruby/object:Gem::Requirement
39
- none: false
40
38
  requirements:
41
39
  - - ! '>='
42
40
  - !ruby/object:Gem::Version
43
41
  version: '0'
44
42
  requirements: []
45
43
  rubyforge_project:
46
- rubygems_version: 1.8.30
44
+ rubygems_version: 2.4.5
47
45
  signing_key:
48
- specification_version: 3
46
+ specification_version: 4
49
47
  summary: Converts strings with ANSI SGR codes to HTML
50
48
  test_files: []