html_to_ansi 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: faf7abed42e123a51749b6b623336e43ad227c4d0318d0322a6eaef890988312
4
+ data.tar.gz: 4dcc23dbca613db1b3afb96909725027572080bdf2dfca6841c8815c869af9fd
5
+ SHA512:
6
+ metadata.gz: 117a42d669b76e50e31a9fca72af4f193ce0b4e89f293be0879ae476e6472882da8b037d0ae49b35c89ba5e2c61cd5d0a7ae847b40445ad9e2b874f2844755b7
7
+ data.tar.gz: fd1ef67c61cc24b1b48c5fae5c5706b9348004764a1e0f9f54ba46a6307ee1c05ab3e4374b913daf08c697c5c8c56d8bd9af49f292cf793e50a050aeba781f37
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.3
7
+ before_install: gem install bundler -v 2.0.1
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in html_to_ansi.gemspec
4
+ gemspec
@@ -0,0 +1,43 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ html_to_ansi (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.3)
10
+ docile (1.3.1)
11
+ json (2.2.0)
12
+ rake (10.5.0)
13
+ rspec (3.8.0)
14
+ rspec-core (~> 3.8.0)
15
+ rspec-expectations (~> 3.8.0)
16
+ rspec-mocks (~> 3.8.0)
17
+ rspec-core (3.8.0)
18
+ rspec-support (~> 3.8.0)
19
+ rspec-expectations (3.8.2)
20
+ diff-lcs (>= 1.2.0, < 2.0)
21
+ rspec-support (~> 3.8.0)
22
+ rspec-mocks (3.8.0)
23
+ diff-lcs (>= 1.2.0, < 2.0)
24
+ rspec-support (~> 3.8.0)
25
+ rspec-support (3.8.0)
26
+ simplecov (0.16.1)
27
+ docile (~> 1.1)
28
+ json (>= 1.8, < 3)
29
+ simplecov-html (~> 0.10.0)
30
+ simplecov-html (0.10.2)
31
+
32
+ PLATFORMS
33
+ x64-mingw32
34
+
35
+ DEPENDENCIES
36
+ bundler (~> 2.0)
37
+ html_to_ansi!
38
+ rake (~> 10.0)
39
+ rspec (~> 3.0)
40
+ simplecov (~> 0.14)
41
+
42
+ BUNDLED WITH
43
+ 2.0.1
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Fred Snyder
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,39 @@
1
+ # HtmlToAnsi
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/html_to_ansi`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'html_to_ansi'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install html_to_ansi
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/html_to_ansi.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,28 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "html_to_ansi/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "html_to_ansi"
8
+ spec.version = HtmlToAnsi::VERSION
9
+ spec.authors = ["Fred Snyder"]
10
+ spec.email = ["fsnyder@castwide.com"]
11
+
12
+ spec.summary = "HTML to ANSI conversion tool"
13
+ spec.description = "Generate ANSI text with escape sequences to emulate basic HTML formatting."
14
+ spec.homepage = "http://castwide.com"
15
+ spec.license = "MIT"
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|bin)/}) }
21
+ end
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 2.0"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec", "~> 3.0"
27
+ spec.add_development_dependency "simplecov", "~> 0.14"
28
+ end
@@ -0,0 +1,16 @@
1
+ require "html_to_ansi/version"
2
+
3
+ module HtmlToAnsi
4
+ autoload :Ansi, 'html_to_ansi/ansi'
5
+ autoload :Html, 'html_to_ansi/html'
6
+
7
+ ESCAPE_REGEXP = /\x1b[^m]*m/
8
+
9
+ def self.convert html, wrap: true, width: nil
10
+ Html::Conversions.html_to_ansi html, wrap: wrap, width: width
11
+ end
12
+
13
+ def self.unescape ansi
14
+ ansi.gsub(ESCAPE_REGEXP, '')
15
+ end
16
+ end
@@ -0,0 +1,49 @@
1
+ # Constants for ANSI codes, plus ExtraCodes for custom formatting.
2
+ module HtmlToAnsi::Ansi
3
+ module Code
4
+ module Attribute
5
+ NORMAL = 0
6
+ BOLD = 1
7
+ UNDERSCORE = 4
8
+ BLINK = 5
9
+ REVERSE = 7
10
+ CONCEALED = 8
11
+ end
12
+ module Foreground
13
+ BLACK = 30
14
+ RED = 31
15
+ GREEN = 32
16
+ YELLOW = 33
17
+ BLUE = 34
18
+ MAGENTA = 35
19
+ CYAN = 36
20
+ WHITE = 37
21
+ end
22
+ module Background
23
+ BLACK = 40
24
+ RED = 41
25
+ GREEN = 42
26
+ YELLOW = 43
27
+ BLUE = 44
28
+ MAGENTA = 45
29
+ CYAN = 46
30
+ WHITE = 47
31
+ end
32
+ module Extra
33
+ BLOCK = :block
34
+ PRE = :pre
35
+ HREF = :href
36
+ IMAGE = :image
37
+ SRC = :src
38
+ UPPERCASE = :uppercase
39
+ COMMAND = :command
40
+ IGNORED = :ignored
41
+ LINE = :line
42
+ end
43
+ end
44
+ def self.graphics_mode(*settings)
45
+ ansi = settings.flatten.select { |s| s.is_a?(Integer) }
46
+ return '' if ansi.length == 0
47
+ "\e[#{ansi.join(';')}m"
48
+ end
49
+ end
@@ -0,0 +1,65 @@
1
+ require 'rexml/document'
2
+ require 'html_to_ansi/html/entities'
3
+
4
+ module HtmlToAnsi
5
+ module Html
6
+ autoload :Conversions, 'html_to_ansi/html/conversions'
7
+
8
+ # Convert ampersands to &amp;
9
+ #
10
+ # @param text [String]
11
+ # @return [String]
12
+ def self.fix_ampersands(text)
13
+ codes = []
14
+ ENTITIES.keys.each { |e|
15
+ codes.push e[1..-1]
16
+ }
17
+ piped = codes.join('|')
18
+ re = Regexp.new("&(?!(#{piped}))")
19
+ text.gsub(re, '&amp;\1')
20
+ end
21
+
22
+ # Encode a String with HTML entities
23
+ #
24
+ # @param text [String]
25
+ # @return [String]
26
+ def self.encode(text)
27
+ encoded = text
28
+ ENTITIES.each { |k, v|
29
+ encoded = encoded.gsub(v, k)
30
+ }
31
+ encoded
32
+ end
33
+
34
+ # Decode a String's HTML entities
35
+ #
36
+ # @param text [String]
37
+ # @return [String]
38
+ def self.decode(text)
39
+ ENTITIES.each { |k, v|
40
+ text = text.gsub(k, v)
41
+ }
42
+ text
43
+ end
44
+
45
+ # Parse a String into an XML document
46
+ #
47
+ # @param code [String]
48
+ # @return [REXML::Document]
49
+ def self.parse(code)
50
+ code = fix_ampersands(code).strip
51
+ last = nil
52
+ begin
53
+ doc = REXML::Document.new code
54
+ rescue REXML::ParseException => e
55
+ # Convert invalid < characters to &lt;
56
+ if e.source.buffer != last and e.source.buffer[0,1] == '<'
57
+ code = code[0,(code.length - e.source.buffer.length)] + '&lt;' + e.source.buffer[1..-1]
58
+ last = e.source.buffer
59
+ retry
60
+ end
61
+ raise e
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,238 @@
1
+ module HtmlToAnsi
2
+
3
+ module Html
4
+ module Conversions
5
+ def self.html_to_ansi text, wrap: true, width: nil
6
+ return '' if text.strip == ''
7
+ output = ''
8
+ begin
9
+ doc = Html.parse("<body>#{text.gsub(/\r/, '').strip}</body>")
10
+ output = AnsiFormatter.new.format(doc) + Ansi.graphics_mode(Ansi::Code::Attribute::NORMAL)
11
+ output = Html.decode(output)
12
+ rescue REXML::ParseException => e
13
+ output = text.strip
14
+ end
15
+ calc_width = width || size[0]
16
+ if calc_width.nil? or !wrap
17
+ output
18
+ else
19
+ terminalize(output, calc_width - 1)
20
+ end
21
+ end
22
+
23
+ def self.html_to_text text, wrap: true, width: nil
24
+ text = html_to_ansi text, wrap: wrap, width: width
25
+ text.gsub(/\e\[([;\d]+)?m/, '').gsub(/\n +\n/, "\n\n")
26
+ end
27
+
28
+ class AnsiNode
29
+ include Ansi::Code
30
+ attr_accessor :parent
31
+
32
+ def render
33
+ end
34
+
35
+ def in_block?
36
+ parent.kind_of?(BlockNode)
37
+ end
38
+ end
39
+ private_constant :AnsiNode
40
+
41
+ class TextNode < AnsiNode
42
+ @@prev_format = nil
43
+ attr_reader :text, :format
44
+ def initialize text, format
45
+ @text = text
46
+ @format = format
47
+ end
48
+ def render
49
+ return @text if format.include?(Extra::PRE)
50
+ index = parent.children.index(self)
51
+ if index > 0
52
+ prev = parent.children[index - 1]
53
+ if prev.kind_of?(TextNode) and prev.format == format
54
+ if prev.text.match(/ $/)
55
+ return @text.lstrip
56
+ else
57
+ return @text
58
+ end
59
+ end
60
+ end
61
+ if @@prev_format == format
62
+ @text
63
+ else
64
+ @prev_format = format
65
+ HtmlToAnsi::Ansi.graphics_mode(*format) + @text
66
+ end
67
+ end
68
+ end
69
+ private_constant :TextNode
70
+
71
+ class ElementNode < AnsiNode
72
+ def children
73
+ @children ||= []
74
+ end
75
+ def append child
76
+ children.push child
77
+ child.parent = self
78
+ end
79
+ end
80
+ private_constant :ElementNode
81
+
82
+ class BlockNode < ElementNode
83
+ def render
84
+ output = ''
85
+ children.each { |c|
86
+ output += c.render
87
+ }
88
+ output = "\n" + output.strip unless in_block?
89
+ output
90
+ end
91
+ end
92
+ private_constant :BlockNode
93
+
94
+ class InlineNode < ElementNode
95
+ def render
96
+ output = ''
97
+ children.each { |c|
98
+ output += c.render
99
+ output += "\n" if c.kind_of?(BlockNode)
100
+ }
101
+ output
102
+ end
103
+ end
104
+ private_constant :InlineNode
105
+
106
+ class BreakNode < ElementNode
107
+ def render
108
+ output = ''
109
+ children.each { |c|
110
+ output += c.render
111
+ }
112
+ output + "\n"
113
+ end
114
+ end
115
+ private_constant :BreakNode
116
+
117
+ class AnsiFormatter
118
+ include HtmlToAnsi::Ansi::Code
119
+ def format document
120
+ @document = document
121
+ @ansi_root = InlineNode.new
122
+ @list_index = []
123
+ format_recursively @document.root, @ansi_root, [Attribute::NORMAL]
124
+ output = @ansi_root.render
125
+ output += (@ansi_root.children.last.kind_of?(BlockNode) ? "\n" : "")
126
+ end
127
+
128
+ def format_recursively element, ansi_node, stack
129
+ if element.is_a?(REXML::Text)
130
+ append_text element, ansi_node, stack
131
+ else
132
+ current = []
133
+ case element.name
134
+ when 'b', 'strong', 'em'
135
+ current.push Attribute::BOLD
136
+ format_children element, ansi_node, stack + current
137
+ when 'i', 'u'
138
+ current.push Attribute::UNDERSCORE
139
+ format_children element, ansi_node, stack + current
140
+ when 'h1', 'h2', 'h3', 'h4', 'h5'
141
+ current.push Attribute::BOLD, Extra::UPPERCASE
142
+ format_paragraph element, ansi_node, stack + current
143
+ when 'p'
144
+ format_paragraph element, ansi_node, stack
145
+ when 'ol', 'ul'
146
+ @list_index.push 0
147
+ format_paragraph element, ansi_node, stack
148
+ @list_index.pop
149
+ when 'li'
150
+ format_list_item element, ansi_node, stack
151
+ when 'pre'
152
+ current.push Extra::PRE
153
+ format_children element, ansi_node, stack + current
154
+ when 'br'
155
+ ansi_node.append TextNode.new("\n", stack + [Extra::PRE])
156
+ else
157
+ format_children element, ansi_node, stack
158
+ end
159
+ end
160
+ end
161
+
162
+ def append_text element, ansi_node, stack
163
+ text = element.to_s
164
+ text.gsub!(/[\s]+/, ' ') unless stack.include?(Extra::PRE)
165
+ text.upcase! if stack.include?(Extra::UPPERCASE)
166
+ ansi_node.append TextNode.new(text, stack)
167
+ end
168
+
169
+ def format_children element, node, stack
170
+ element.each { |e|
171
+ format_recursively e, node, stack
172
+ }
173
+ end
174
+
175
+ def format_paragraph element, node, stack
176
+ paragraph = BlockNode.new
177
+ node.append paragraph
178
+ format_children element, paragraph, stack
179
+ end
180
+
181
+ def format_list_item element, node, stack
182
+ i = 0
183
+ unless @list_index.empty?
184
+ @list_index[-1] = @list_index[-1] + 1
185
+ i = @list_index[-1]
186
+ end
187
+ b = BreakNode.new
188
+ node.append b
189
+ if element.parent.name == 'ol'
190
+ b.append TextNode.new("#{i}. ", stack)
191
+ else
192
+ b.append TextNode.new("* ", stack)
193
+ end
194
+ format_children element, b, stack
195
+ end
196
+ end
197
+ private_constant :AnsiFormatter
198
+
199
+ def self.terminalize string, max_length
200
+ i = 0
201
+ output = ''
202
+ line_length = 0
203
+ while i < string.length
204
+ line_length += 1
205
+ char = string[i,1]
206
+ if char == "\e"
207
+ # Right now, graphics modes are the only supported ANSI sequences.
208
+ end_of_seq = string.index("m", i)
209
+ output += string[i..end_of_seq]
210
+ i = end_of_seq + 1
211
+ elsif char == " "
212
+ next_space = string.index(/[\s]/, i + 1)
213
+ if !next_space.nil? and line_length + (next_space - i) > max_length
214
+ output += "\n"
215
+ line_length = 0
216
+ else
217
+ output += char
218
+ end
219
+ i += 1
220
+ else
221
+ if char == "\n"
222
+ line_length = 0
223
+ end
224
+ output += char
225
+ i += 1
226
+ end
227
+ end
228
+ output
229
+ end
230
+
231
+ def self.size
232
+ STDOUT.winsize.reverse
233
+ rescue
234
+ [nil,nil]
235
+ end
236
+ end
237
+ end
238
+ end
@@ -0,0 +1,5 @@
1
+ module HtmlToAnsi
2
+ module Html
3
+ ENTITIES = { "&quot;" => "\"", "&amp;" => "&", "&lt;" => "<", "&gt;" => ">", "&nbsp;" => " ", "&iexcl;" => "¡", "&cent;" => "¢", "&pound;" => "£", "&curren;" => "¤", "&yen;" => "¥", "&brvbar;" => "¦", "&sect;" => "§", "&uml;" => "¨", "&copy;" => "©", "&ordf;" => "ª", "&laquo;" => "«", "&not;" => "¬", "&shy;" => "­", "&reg;" => "®", "&macr;" => "¯", "&deg;" => "°", "&plusmn;" => "±", "&sup2;" => "²", "&sup3;" => "³", "&acute;" => "´", "&micro;" => "µ", "&para;" => "¶", "&middot;" => "·", "&cedil;" => "¸", "&sup1;" => "¹", "&ordm;" => "º", "&raquo;" => "»", "&frac14;" => "¼", "&frac12;" => "½", "&frac34;" => "¾", "&iquest;" => "¿", "&Agrave;" => "À", "&Aacute;" => "Á", "&Acirc;" => "Â", "&Atilde;" => "Ã", "&Auml;" => "Ä", "&Aring;" => "Å", "&AElig;" => "Æ", "&Ccedil;" => "Ç", "&Egrave;" => "È", "&Eacute;" => "É", "&Ecirc;" => "Ê", "&Euml;" => "Ë", "&Igrave;" => "Ì", "&Iacute;" => "Í", "&Icirc;" => "Î", "&Iuml;" => "Ï", "&ETH;" => "Ð", "&Ntilde;" => "Ñ", "&Ograve;" => "Ò", "&Oacute;" => "Ó", "&Ocirc;" => "Ô", "&Otilde;" => "Õ", "&Ouml;" => "Ö", "&times;" => "×", "&Oslash;" => "Ø", "&Ugrave;" => "Ù", "&Uacute;" => "Ú", "&Ucirc;" => "Û", "&Uuml;" => "Ü", "&Yacute;" => "Ý", "&THORN;" => "Þ", "&szlig;" => "ß", "&agrave;" => "à", "&aacute;" => "á", "&acirc;" => "â", "&atilde;" => "ã", "&auml;" => "ä", "&aring;" => "å", "&aelig;" => "æ", "&ccedil;" => "ç", "&egrave;" => "è", "&eacute;" => "é", "&ecirc;" => "ê", "&euml;" => "ë", "&igrave;" => "ì", "&iacute;" => "í", "&icirc;" => "î", "&iuml;" => "ï", "&eth;" => "ð", "&ntilde;" => "ñ", "&ograve;" => "ò", "&oacute;" => "ó", "&ocirc;" => "ô", "&otilde;" => "õ", "&ouml;" => "ö", "&divide;" => "÷", "&oslash;" => "ø", "&ugrave;" => "ù", "&uacute;" => "ú", "&ucirc;" => "û", "&uuml;" => "ü", "&yacute;" => "ý", "&thorn;" => "þ", "&yuml;" => "ÿ", "&OElig;" => "Œ", "&oelig;" => "œ", "&Scaron;" => "Š", "&scaron;" => "š", "&Yuml;" => "Ÿ", "&fnof;" => "ƒ", "&circ;" => "ˆ", "&tilde;" => "˜", "&Alpha;" => "Α", "&Beta;" => "Β", "&Gamma;" => "Γ", "&Delta;" => "Δ", "&Epsilon;" => "Ε", "&Zeta;" => "Ζ", "&Eta;" => "Η", "&Theta;" => "Θ", "&Iota;" => "Ι", "&Kappa;" => "Κ", "&Lambda;" => "Λ", "&Mu;" => "Μ", "&Nu;" => "Ν", "&Xi;" => "Ξ", "&Omicron;" => "Ο", "&Pi;" => "Π", "&Rho;" => "Ρ", "&Sigma;" => "Σ", "&Tau;" => "Τ", "&Upsilon;" => "Υ", "&Phi;" => "Φ", "&Chi;" => "Χ", "&Psi;" => "Ψ", "&Omega;" => "Ω", "&alpha;" => "α", "&beta;" => "β", "&gamma;" => "γ", "&delta;" => "δ", "&epsilon;" => "ε", "&zeta;" => "ζ", "&eta;" => "η", "&theta;" => "θ", "&iota;" => "ι", "&kappa;" => "κ", "&lambda;" => "λ", "&mu;" => "μ", "&nu;" => "ν", "&xi;" => "ξ", "&omicron;" => "ο", "&pi;" => "π", "&rho;" => "ρ", "&sigmaf;" => "ς", "&sigma;" => "σ", "&tau;" => "τ", "&upsilon;" => "υ", "&phi;" => "φ", "&chi;" => "χ", "&psi;" => "ψ", "&omega;" => "ω", "&thetasym;" => "ϑ", "&upsih;" => "ϒ", "&piv;" => "ϖ", "&ensp;" => " ", "&emsp;" => " ", "&thinsp;" => " ", "&zwnj;" => "‌", "&zwj;" => "‍", "&lrm;" => "‎", "&rlm;" => "‏", "&ndash;" => "–", "&mdash;" => "—", "&lsquo;" => "‘", "&rsquo;" => "’", "&sbquo;" => "‚", "&ldquo;" => "“", "&rdquo;" => "”", "&bdquo;" => "„", "&dagger;" => "†", "&Dagger;" => "‡", "&bull;" => "•", "&hellip;" => "…", "&permil;" => "‰", "&prime;" => "′", "&Prime;" => "″", "&lsaquo;" => "‹", "&rsaquo;" => "›", "&oline;" => "‾", "&frasl;" => "⁄", "&euro;" => "€", "&image;" => "ℑ", "&weierp;" => "℘", "&real;" => "ℜ", "&trade;" => "™", "&alefsym;" => "ℵ", "&larr;" => "←", "&uarr;" => "↑", "&rarr;" => "→", "&darr;" => "↓", "&harr;" => "↔", "&crarr;" => "↵", "&lArr;" => "⇐", "&uArr;" => "⇑", "&rArr;" => "⇒", "&dArr;" => "⇓", "&hArr;" => "⇔", "&forall;" => "∀", "&part;" => "∂", "&exist;" => "∃", "&empty;" => "∅", "&nabla;" => "∇", "&isin;" => "∈", "&notin;" => "∉", "&ni;" => "∋", "&prod;" => "∏", "&sum;" => "∑", "&minus;" => "−", "&lowast;" => "∗", "&radic;" => "√", "&prop;" => "∝", "&infin;" => "∞", "&ang;" => "∠", "&and;" => "∧", "&or;" => "∨", "&cap;" => "∩", "&cup;" => "∪", "&int;" => "∫", "&there4;" => "∴", "&sim;" => "∼", "&cong;" => "≅", "&asymp;" => "≈", "&ne;" => "≠", "&equiv;" => "≡", "&le;" => "≤", "&ge;" => "≥", "&sub;" => "⊂", "&sup;" => "⊃", "&nsub;" => "⊄", "&sube;" => "⊆", "&supe;" => "⊇", "&oplus;" => "⊕", "&otimes;" => "⊗", "&perp;" => "⊥", "&sdot;" => "⋅", "&lceil;" => "⌈", "&rceil;" => "⌉", "&lfloor;" => "⌊", "&rfloor;" => "⌋", "&lang;" => "〈", "&rang;" => "〉", "&loz;" => "◊", "&spades;" => "♠", "&clubs;" => "♣", "&hearts;" => "♥", "&diams;" => "♦" }
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module HtmlToAnsi
2
+ VERSION = '0.1.0'
3
+ end
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: html_to_ansi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Fred Snyder
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-04-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: simplecov
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.14'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.14'
69
+ description: Generate ANSI text with escape sequences to emulate basic HTML formatting.
70
+ email:
71
+ - fsnyder@castwide.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - Gemfile.lock
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - html_to_ansi.gemspec
85
+ - lib/html_to_ansi.rb
86
+ - lib/html_to_ansi/ansi.rb
87
+ - lib/html_to_ansi/html.rb
88
+ - lib/html_to_ansi/html/conversions.rb
89
+ - lib/html_to_ansi/html/entities.rb
90
+ - lib/html_to_ansi/version.rb
91
+ homepage: http://castwide.com
92
+ licenses:
93
+ - MIT
94
+ metadata: {}
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubygems_version: 3.0.3
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: HTML to ANSI conversion tool
114
+ test_files: []