ansi2html 5.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ Gemfile.lock
2
+ pkg
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm @ansi2html --create
data/COPYING ADDED
@@ -0,0 +1,12 @@
1
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
2
+ Version 2, December 2004
3
+
4
+ Copyright (C) 2011 Aslak Hellesøy
5
+ Everyone is permitted to copy and distribute verbatim or modified
6
+ copies of this license document, and changing it is allowed as long
7
+ as the name is changed.
8
+
9
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
10
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
11
+
12
+ 0. You just DO WHAT THE FUCK YOU WANT TO.
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source "http://rubygems.org"
2
+ gemspec
data/History.txt ADDED
@@ -0,0 +1,3 @@
1
+ = 5.3.2
2
+
3
+ Wah! Wah! Wah! Wah! Wah! Wah!
data/README.rdoc ADDED
@@ -0,0 +1,34 @@
1
+ = ansi2html
2
+
3
+ You have class. You are a hipster. You ride a fixie bike to work and you are member of a Scotch Whisky club.
4
+ When using a computer, you prefer minimalistic command line applications that output ANSI colours in your
5
+ terminal that you have configured to have semi-transparent background with Frank Zappa background music and
6
+ vim-like shortcuts that differentiates you from the common programmers. You are a big fish in a small pond.
7
+
8
+ Your friends are not geeks like you, they have more important goals in their lives, but they admire you for being
9
+ so smart, because you can write computer programs. Programs with ANSI colours even. And yet, they don't know how
10
+ to use a terminal.
11
+
12
+ You need a way to show your entourage the true power of ANSI colours. -A way that works with the iPad.
13
+
14
+ You will just
15
+
16
+ gem install ansi2html
17
+ curl github.com/aslakhellesoy/ansi2html/raw/master/examples/summering_feil.txt | ansi2html --envelope > summering_feil.html
18
+ open summering_feil.html
19
+
20
+ OMG you have a LINUX machine so you will do {TODO WTF is the equivalent of open in LINUX} to open the file.
21
+ ZOMFG you have WINDOWS. You'll figure out what to do. It works the same as a .htm file.
22
+
23
+ HTML designers have a special option. Don't use --envelope. This will give you HTML with Scandinavian design instead. Just pump input in and
24
+ stick the output in your new fancy <article> and <section> fancy page with CSS3 yo. (It will explode if you have rounded corners). Nobody
25
+ does that anymore. Please.
26
+
27
+ Let's tweet #ansi2html with links to pages that have ANSI in HTML now, ok? (I would, but my home page is under construction, besides
28
+ I don't promote my own art because I am an artist).
29
+
30
+ == HALP
31
+
32
+ Send me a pull request if you fixed something. This will get you started (after you install ruby):
33
+
34
+ gem install bundler && bundle install && rspec spec
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # encoding: utf-8
2
+ require 'rubygems'
3
+ require 'bundler/setup'
4
+ Bundler::GemHelper.install_tasks
data/ansi2html.gemspec ADDED
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'ansi2html'
5
+ s.version = '5.3.2'
6
+ s.authors = ["Aslak Hellesøy"]
7
+ s.description = 'Convert ANSI escape sequences to styleable HTML markup'
8
+ s.summary = "#{s.name}-#{s.version}"
9
+ s.email = 'aslak.hellesoy@gmail.com'
10
+ s.homepage = 'http://github.com/aslakhellesoy/#{s.name}'
11
+
12
+ s.add_development_dependency 'rspec', '~> 2.3.0'
13
+
14
+ s.rubygems_version = "1.3.7"
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.extra_rdoc_files = ["COPYING", "README.rdoc", "History.txt"]
19
+ s.rdoc_options = ["--charset=UTF-8"]
20
+ s.require_path = "lib"
21
+ end
22
+
data/bin/ansi2html ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift(File.dirname(__FILE__) + '/../lib') unless $:.include?(File.dirname(__FILE__) + '/../lib')
3
+
4
+ require 'ansi2html/main'
5
+ begin
6
+ failure = ANSI2HTML::Main.execute
7
+ Kernel.exit(1) if failure
8
+ rescue SystemExit => e
9
+ Kernel.exit(e.status)
10
+ rescue Exception => e
11
+ STDERR.puts("#{e.message} (#{e.class})")
12
+ STDERR.puts(e.backtrace.join("\n"))
13
+ Kernel.exit(1)
14
+ end
@@ -0,0 +1,4 @@
1
+ h1. Examples
2
+
3
+ When you have read the uber README you will know what to do. You should be able to recreate the .html file from the .txt file.
4
+ That's an exercise for you. If you can't do it you should study harder.
@@ -0,0 +1,74 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <style>
6
+ .bold {
7
+ font-weight: bold;
8
+ }
9
+ .black {
10
+ color: black;
11
+ }
12
+ .red {
13
+ color: red;
14
+ }
15
+ .green {
16
+ color: green;
17
+ }
18
+ .yellow {
19
+ color: yellow;
20
+ }
21
+ .blue {
22
+ color: blue;
23
+ }
24
+ .magenta {
25
+ color: magenta;
26
+ }
27
+ .cyan {
28
+ color: cyan;
29
+ }
30
+ .white {
31
+ color: white;
32
+ }
33
+ .grey {
34
+ color: grey;
35
+ }
36
+ </style>
37
+ </head>
38
+ <body><pre><code>Using the default profile...
39
+ # language: no
40
+ Egenskap: Summering
41
+ For å slippe å gjøre dumme feil
42
+ Som en regnskapsfører
43
+ Vil jeg kunne legge sammen
44
+
45
+ Scenario: to tall<span class="grey"> # examples/i18n/no/features/summering.feature:7</span>
46
+ <span class="green">Gitt at jeg har tastet inn <span class="green"><span class="bold">5</span></span><span class="green"><span class="grey"> # examples/i18n/no/features/step_definitons/kalkulator_steps.rb:7</span></span>
47
+ <span class="green">Og at jeg har tastet inn <span class="green"><span class="bold">7</span></span><span class="green"><span class="grey"> # examples/i18n/no/features/step_definitons/kalkulator_steps.rb:7</span></span>
48
+ <span class="green">Når jeg summerer<span class="grey"> # examples/i18n/no/features/step_definitons/kalkulator_steps.rb:11</span></span>
49
+ <span class="red">Så skal resultatet være <span class="red"><span class="bold">12</span></span><span class="red"><span class="grey"> # examples/i18n/no/features/step_definitons/kalkulator_steps.rb:15</span></span>
50
+ <span class="red"> expected: 12,
51
+ got: 14 (using ==) (RSpec::Expectations::ExpectationNotMetError)
52
+ ./examples/i18n/no/features/step_definitons/kalkulator_steps.rb:16:in `/skal resultatet være (\d*)/'
53
+ examples/i18n/no/features/summering.feature:11:in `Så skal resultatet være 12'</span>
54
+
55
+ <span class="cyan">@iterasjon3</span>
56
+ Scenario: tre tall<span class="grey"> # examples/i18n/no/features/summering.feature:14</span>
57
+ <span class="green">Gitt at jeg har tastet inn <span class="green"><span class="bold">5</span></span><span class="green"><span class="grey"> # examples/i18n/no/features/step_definitons/kalkulator_steps.rb:7</span></span>
58
+ <span class="green">Og at jeg har tastet inn <span class="green"><span class="bold">7</span></span><span class="green"><span class="grey"> # examples/i18n/no/features/step_definitons/kalkulator_steps.rb:7</span></span>
59
+ <span class="green">Og at jeg har tastet inn <span class="green"><span class="bold">1</span></span><span class="green"><span class="grey"> # examples/i18n/no/features/step_definitons/kalkulator_steps.rb:7</span></span>
60
+ <span class="green">Når jeg summerer<span class="grey"> # examples/i18n/no/features/step_definitons/kalkulator_steps.rb:11</span></span>
61
+ <span class="red">Så skal resultatet være <span class="red"><span class="bold">13</span></span><span class="red"><span class="grey"> # examples/i18n/no/features/step_definitons/kalkulator_steps.rb:15</span></span>
62
+ <span class="red"> expected: 13,
63
+ got: 16 (using ==) (RSpec::Expectations::ExpectationNotMetError)
64
+ ./examples/i18n/no/features/step_definitons/kalkulator_steps.rb:16:in `/skal resultatet være (\d*)/'
65
+ examples/i18n/no/features/summering.feature:19:in `Så skal resultatet være 13'</span>
66
+
67
+ <span class="red">Failing Scenarios:</span>
68
+ <span class="red">cucumber examples/i18n/no/features/summering.feature:7</span><span class="grey"> # Scenario: to tall</span>
69
+ <span class="red">cucumber examples/i18n/no/features/summering.feature:14</span><span class="grey"> # Scenario: tre tall</span>
70
+
71
+ 2 scenarios (<span class="red">2 failed</span>)
72
+ 9 steps (<span class="red">2 failed</span>, <span class="green">7 passed</span>)
73
+ 0m0.005s
74
+ </code></pre></body></html>
@@ -0,0 +1,36 @@
1
+ Using the default profile...
2
+ # language: no
3
+ Egenskap: Summering
4
+ For å slippe å gjøre dumme feil
5
+ Som en regnskapsfører
6
+ Vil jeg kunne legge sammen
7
+
8
+ Scenario: to tall # examples/i18n/no/features/summering.feature:7
9
+ Gitt at jeg har tastet inn 5 # examples/i18n/no/features/step_definitons/kalkulator_steps.rb:7
10
+ Og at jeg har tastet inn 7 # examples/i18n/no/features/step_definitons/kalkulator_steps.rb:7
11
+ Når jeg summerer # examples/i18n/no/features/step_definitons/kalkulator_steps.rb:11
12
+ Så skal resultatet være 12 # examples/i18n/no/features/step_definitons/kalkulator_steps.rb:15
13
+  expected: 12,
14
+ got: 14 (using ==) (RSpec::Expectations::ExpectationNotMetError)
15
+ ./examples/i18n/no/features/step_definitons/kalkulator_steps.rb:16:in `/skal resultatet være (\d*)/'
16
+ examples/i18n/no/features/summering.feature:11:in `Så skal resultatet være 12'
17
+
18
+ @iterasjon3
19
+ Scenario: tre tall # examples/i18n/no/features/summering.feature:14
20
+ Gitt at jeg har tastet inn 5 # examples/i18n/no/features/step_definitons/kalkulator_steps.rb:7
21
+ Og at jeg har tastet inn 7 # examples/i18n/no/features/step_definitons/kalkulator_steps.rb:7
22
+ Og at jeg har tastet inn 1 # examples/i18n/no/features/step_definitons/kalkulator_steps.rb:7
23
+ Når jeg summerer # examples/i18n/no/features/step_definitons/kalkulator_steps.rb:11
24
+ Så skal resultatet være 13 # examples/i18n/no/features/step_definitons/kalkulator_steps.rb:15
25
+  expected: 13,
26
+ got: 16 (using ==) (RSpec::Expectations::ExpectationNotMetError)
27
+ ./examples/i18n/no/features/step_definitons/kalkulator_steps.rb:16:in `/skal resultatet være (\d*)/'
28
+ examples/i18n/no/features/summering.feature:19:in `Så skal resultatet være 13'
29
+
30
+ Failing Scenarios:
31
+ cucumber examples/i18n/no/features/summering.feature:7 # Scenario: to tall
32
+ cucumber examples/i18n/no/features/summering.feature:14 # Scenario: tre tall
33
+
34
+ 2 scenarios (2 failed)
35
+ 9 steps (2 failed, 7 passed)
36
+ 0m0.005s
@@ -0,0 +1,81 @@
1
+ require 'strscan'
2
+
3
+ module ANSI2HTML
4
+ class Main
5
+ COLOR = {
6
+ '1' => 'bold',
7
+ '30' => 'black',
8
+ '31' => 'red',
9
+ '32' => 'green',
10
+ '33' => 'yellow',
11
+ '34' => 'blue',
12
+ '35' => 'magenta',
13
+ '36' => 'cyan',
14
+ '37' => 'white',
15
+ '90' => 'grey'
16
+ }
17
+
18
+ def self.execute
19
+ new(STDIN.read, STDOUT, ARGV.index('--envelope'))
20
+ end
21
+
22
+ def initialize(ansi, out, envelope=false)
23
+ if(envelope)
24
+ out.print %{<!doctype html>
25
+ <html>
26
+ <head>
27
+ <meta charset="utf-8" />
28
+ <style>
29
+ .bold {
30
+ font-weight: bold;
31
+ }
32
+ .black {
33
+ color: black;
34
+ }
35
+ .red {
36
+ color: red;
37
+ }
38
+ .green {
39
+ color: green;
40
+ }
41
+ .yellow {
42
+ color: yellow;
43
+ }
44
+ .blue {
45
+ color: blue;
46
+ }
47
+ .magenta {
48
+ color: magenta;
49
+ }
50
+ .cyan {
51
+ color: cyan;
52
+ }
53
+ .white {
54
+ color: white;
55
+ }
56
+ .grey {
57
+ color: grey;
58
+ }
59
+ </style>
60
+ </head>
61
+ <body><pre><code>}
62
+ end
63
+ s = StringScanner.new(ansi)
64
+ while(!s.eos?)
65
+ if s.scan(/\e\[(3[0-7]|90|1)m/)
66
+ out.print(%{<span class="#{COLOR[s[1]]}">})
67
+ else
68
+ if s.scan(/\e\[0m/)
69
+ out.print(%{</span>})
70
+ else
71
+ out.print(s.scan(/./m))
72
+ end
73
+ end
74
+ end
75
+
76
+ if(envelope)
77
+ out.print %{</code></pre></body></html>}
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,19 @@
1
+ npm info it worked if it ends with ok
2
+ npm info using npm@0.2.12-1
3
+ npm info using node@v0.2.5
4
+ npm info preinstall express@1.0.1
5
+ npm info install express@1.0.1
6
+ npm info postinstall express@1.0.1
7
+ npm info predeactivate express@1.0.1
8
+ npm info deactivate express@1.0.1
9
+ npm info postdeactivate express@1.0.1
10
+ npm info preactivate express@1.0.1
11
+ npm info activate express@1.0.1
12
+ npm info postactivate express@1.0.1
13
+ npm info preupdatedependents express@1.0.1
14
+ npm info not updating express@1.0.1 doesn't satisfy cukepatch-store@0.1.0
15
+ npm info updatedependents express@1.0.1
16
+ npm info postupdatedependents express@1.0.1
17
+ npm info updated dependents [ 'express@1.0.1' ]
18
+ npm info build Success: express@1.0.1
19
+ npm ok
@@ -0,0 +1,42 @@
1
+ require 'stringio'
2
+ require 'ansi2html/main'
3
+
4
+ module ANSI2HTML
5
+ describe Main do
6
+ it "prints non-ansi as-is" do
7
+ out = StringIO.new
8
+ Main.new("Hello", out)
9
+ out.string.should == 'Hello'
10
+ end
11
+
12
+ it "prints simply red" do
13
+ out = StringIO.new
14
+ Main.new("\e[31mHello\e[0m", out)
15
+ out.string.should == '<span class="red">Hello</span>'
16
+ end
17
+
18
+ it "prints simply yellow" do
19
+ out = StringIO.new
20
+ Main.new("\e[33mHello\e[0m", out)
21
+ out.string.should == '<span class="yellow">Hello</span>'
22
+ end
23
+
24
+ it "prints simply blue" do
25
+ out = StringIO.new
26
+ Main.new("\e[34mHello\e[0m", out)
27
+ out.string.should == '<span class="blue">Hello</span>'
28
+ end
29
+
30
+ it "prints simply grey" do
31
+ out = StringIO.new
32
+ Main.new("\e[90mHello\e[0m", out)
33
+ out.string.should == '<span class="grey">Hello</span>'
34
+ end
35
+
36
+ it "white bold boys have more fun" do
37
+ out = StringIO.new
38
+ Main.new("\e[37m\e[1mHello\e[0m\e[0m", out)
39
+ out.string.should == '<span class="white"><span class="bold">Hello</span></span>'
40
+ end
41
+ end
42
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ansi2html
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 5
7
+ - 3
8
+ - 2
9
+ version: 5.3.2
10
+ platform: ruby
11
+ authors:
12
+ - "Aslak Helles\xC3\xB8y"
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-01-04 00:00:00 -06:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rspec
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 2
29
+ - 3
30
+ - 0
31
+ version: 2.3.0
32
+ type: :development
33
+ prerelease: false
34
+ version_requirements: *id001
35
+ description: Convert ANSI escape sequences to styleable HTML markup
36
+ email: aslak.hellesoy@gmail.com
37
+ executables:
38
+ - ansi2html
39
+ extensions: []
40
+
41
+ extra_rdoc_files:
42
+ - COPYING
43
+ - README.rdoc
44
+ - History.txt
45
+ files:
46
+ - .gitignore
47
+ - .rspec
48
+ - .rvmrc
49
+ - COPYING
50
+ - Gemfile
51
+ - History.txt
52
+ - README.rdoc
53
+ - Rakefile
54
+ - ansi2html.gemspec
55
+ - bin/ansi2html
56
+ - examples/README.textile
57
+ - examples/summering_feil.html
58
+ - examples/summering_feil.txt
59
+ - lib/ansi2html/main.rb
60
+ - npm_install_express.txt
61
+ - spec/ansi2html/main_spec.rb
62
+ has_rdoc: true
63
+ homepage: http://github.com/aslakhellesoy/#{s.name}
64
+ licenses: []
65
+
66
+ post_install_message:
67
+ rdoc_options:
68
+ - --charset=UTF-8
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ hash: -3190143913115694676
77
+ segments:
78
+ - 0
79
+ version: "0"
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ hash: -3190143913115694676
86
+ segments:
87
+ - 0
88
+ version: "0"
89
+ requirements: []
90
+
91
+ rubyforge_project:
92
+ rubygems_version: 1.3.7
93
+ signing_key:
94
+ specification_version: 3
95
+ summary: ansi2html-5.3.2
96
+ test_files:
97
+ - spec/ansi2html/main_spec.rb