htmlentity_translator 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/htmlentity_translator.gemspec +23 -0
- data/htmlentity_translator.iml +23 -0
- data/lib/htmlentity_translator.rb +6 -0
- data/lib/htmlentity_translator/entity_maper.rb +357 -0
- data/lib/htmlentity_translator/string_instrument.rb +8 -0
- data/lib/htmlentity_translator/version.rb +3 -0
- metadata +86 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9a0f3fa17c3cdc71a595ed02bea988fca90b9ad7
|
4
|
+
data.tar.gz: e3d5bf2d0fa7f87ebd653bed2565dc8ebebd1355
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3ac2bb3e69a597e6a580ff0fdce52678ba138d61400ae3dda10486dadd47018bae2ca5937211ce53ce4368a58c88e1f54d1abb3e266a089c2235870ec2f55e21
|
7
|
+
data.tar.gz: 143eab5b6de295356f7aff29bfef7c8fbdc6e2b2b2b188f0e508ec1f9d2e17b7583b62cf1578ee3e3dc6ac3dc81de6379e0e78372eec5fd81183cf9f5b2ba29d
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2016 Rodrigo Urubatan
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# HtmlentityTranslator
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'htmlentity_translator'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install htmlentity_translator
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it ( https://github.com/[my-github-username]/htmlentity_translator/fork )
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'htmlentity_translator/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "htmlentity_translator"
|
8
|
+
spec.version = HtmlentityTranslator::VERSION
|
9
|
+
spec.authors = ["Rodrigo Urubatan"]
|
10
|
+
spec.email = ["rodrigo@urubatan.com.br"]
|
11
|
+
spec.summary = %q{This gem is a simple library to help add or remove HTML entities to a string}
|
12
|
+
spec.description = %q{This gem is a simple libraty to help add or remoge HTML entities to a string the usage is simple "&this needs to be removedá".decode_entities will remove all HTML entities, and "á now I need it encoded".encode_entities will replace non printable ascii with the corresponding HTML entitites}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<module type="RUBY_MODULE" version="4">
|
3
|
+
<component name="FacetManager">
|
4
|
+
<facet type="gem" name="New Gem">
|
5
|
+
<configuration>
|
6
|
+
<option name="GEM_APP_ROOT_PATH" value="$MODULE_DIR$" />
|
7
|
+
<option name="GEM_APP_TEST_PATH" value="$MODULE_DIR$/test" />
|
8
|
+
<option name="GEM_APP_LIB_PATH" value="$MODULE_DIR$/lib" />
|
9
|
+
</configuration>
|
10
|
+
</facet>
|
11
|
+
</component>
|
12
|
+
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
13
|
+
<exclude-output />
|
14
|
+
<content url="file://$MODULE_DIR$">
|
15
|
+
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
16
|
+
<excludeFolder url="file://$MODULE_DIR$/.bundle" />
|
17
|
+
<excludeFolder url="file://$MODULE_DIR$/vendor/bundle" />
|
18
|
+
</content>
|
19
|
+
<orderEntry type="inheritedJdk" />
|
20
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
21
|
+
<orderEntry type="library" scope="PROVIDED" name="rake (v10.4.2, RVM: ruby-2.1.2) [gem]" level="application" />
|
22
|
+
</component>
|
23
|
+
</module>
|
@@ -0,0 +1,357 @@
|
|
1
|
+
module HtmlentityTranslator
|
2
|
+
module EntityMaper
|
3
|
+
HTML_ENTITIES =[[' ', ' ', ' '],
|
4
|
+
['!', '', '!'],
|
5
|
+
['"', '', '"'],
|
6
|
+
['#', '', '#'],
|
7
|
+
['$', '', '$'],
|
8
|
+
['%', '', '%'],
|
9
|
+
['&', '&', '&'],
|
10
|
+
["'", '', '''],
|
11
|
+
['(', '', '('],
|
12
|
+
[')', '', ')'],
|
13
|
+
['*', '', '*'],
|
14
|
+
['+', '', '+'],
|
15
|
+
[',', '', ','],
|
16
|
+
['-', '', '-'],
|
17
|
+
['.', '', '.'],
|
18
|
+
['/', '', '/'],
|
19
|
+
['0', '', '0'],
|
20
|
+
['1', '', '1'],
|
21
|
+
['2', '', '2'],
|
22
|
+
['3', '', '3'],
|
23
|
+
['4', '', '4'],
|
24
|
+
['5', '', '5'],
|
25
|
+
['6', '', '6'],
|
26
|
+
['7', '', '7'],
|
27
|
+
['8', '', '8'],
|
28
|
+
['9', '', '9'],
|
29
|
+
[':', '', ':'],
|
30
|
+
[';', '', ';'],
|
31
|
+
['<', '<', '<'],
|
32
|
+
['=', '', '='],
|
33
|
+
['>', '>', '>'],
|
34
|
+
['?', '', '?'],
|
35
|
+
['@', '', '@'],
|
36
|
+
['A', '', 'A'],
|
37
|
+
['B', '', 'B'],
|
38
|
+
['C', '', 'C'],
|
39
|
+
['D', '', 'D'],
|
40
|
+
['E', '', 'E'],
|
41
|
+
['F', '', 'F'],
|
42
|
+
['G', '', 'G'],
|
43
|
+
['H', '', 'H'],
|
44
|
+
['I', '', 'I'],
|
45
|
+
['J', '', 'J'],
|
46
|
+
['K', '', 'K'],
|
47
|
+
['L', '', 'L'],
|
48
|
+
['M', '', 'M'],
|
49
|
+
['N', '', 'N'],
|
50
|
+
['O', '', 'O'],
|
51
|
+
['P', '', 'P'],
|
52
|
+
['Q', '', 'Q'],
|
53
|
+
['R', '', 'R'],
|
54
|
+
['S', '', 'S'],
|
55
|
+
['T', '', 'T'],
|
56
|
+
['U', '', 'U'],
|
57
|
+
['V', '', 'V'],
|
58
|
+
['W', '', 'W'],
|
59
|
+
['X', '', 'X'],
|
60
|
+
['Y', '', 'Y'],
|
61
|
+
['Z', '', 'Z'],
|
62
|
+
['[', '', '['],
|
63
|
+
["\\", '', '\'],
|
64
|
+
[']', '', ']'],
|
65
|
+
['^', '', '^'],
|
66
|
+
['_', '', '_'],
|
67
|
+
['`', '', '`'],
|
68
|
+
['a', '', 'a'],
|
69
|
+
['b', '', 'b'],
|
70
|
+
['c', '', 'c'],
|
71
|
+
['d', '', 'd'],
|
72
|
+
['e', '', 'e'],
|
73
|
+
['f', '', 'f'],
|
74
|
+
['g', '', 'g'],
|
75
|
+
['h', '', 'h'],
|
76
|
+
['i', '', 'i'],
|
77
|
+
['j', '', 'j'],
|
78
|
+
['k', '', 'k'],
|
79
|
+
['l', '', 'l'],
|
80
|
+
['m', '', 'm'],
|
81
|
+
['n', '', 'n'],
|
82
|
+
['o', '', 'o'],
|
83
|
+
['p', '', 'p'],
|
84
|
+
['q', '', 'q'],
|
85
|
+
['r', '', 'r'],
|
86
|
+
['s', '', 's'],
|
87
|
+
['t', '', 't'],
|
88
|
+
['u', '', 'u'],
|
89
|
+
['v', '', 'v'],
|
90
|
+
['w', '', 'w'],
|
91
|
+
['x', '', 'x'],
|
92
|
+
['y', '', 'y'],
|
93
|
+
['z', '', 'z'],
|
94
|
+
['{', '', '{'],
|
95
|
+
['|', '', '|'],
|
96
|
+
['}', '', '}'],
|
97
|
+
['~', '', '~'],
|
98
|
+
['À', 'À', 'À'],
|
99
|
+
['Á', 'Á', 'Á'],
|
100
|
+
['Â', 'Â', 'Â'],
|
101
|
+
['Ã', 'Ã', 'Ã'],
|
102
|
+
['Ä', 'Ä', 'Ä'],
|
103
|
+
['Å', 'Å', 'Å'],
|
104
|
+
['Æ', 'Æ', 'Æ'],
|
105
|
+
['Ç', 'Ç', 'Ç'],
|
106
|
+
['È', 'È', 'È'],
|
107
|
+
['É', 'É', 'É'],
|
108
|
+
# Ê Ê
|
109
|
+
['Ë', 'Ë', 'Ë'],
|
110
|
+
['Ì', 'Ì', 'Ì'],
|
111
|
+
['Í', 'Í', 'Í'],
|
112
|
+
['Î', 'Î', 'Î'],
|
113
|
+
['Ï', 'Ï', 'Ï'],
|
114
|
+
['Ð', 'Ð', 'Ð'],
|
115
|
+
['Ñ', 'Ñ', 'Ñ'],
|
116
|
+
['Ò', 'Ò', 'Ò'],
|
117
|
+
['Ó', 'Ó', 'Ó'],
|
118
|
+
['Ô', 'Ô', 'Ô'],
|
119
|
+
['Õ', 'Õ', 'Õ'],
|
120
|
+
['Ö', 'Ö', 'Ö'],
|
121
|
+
['Ø', 'Ø', 'Ø'],
|
122
|
+
['Ù', 'Ù', 'Ù'],
|
123
|
+
['Ú', 'Ú', 'Ú'],
|
124
|
+
['Û', 'Û', 'Û'],
|
125
|
+
['Ü', 'Ü', 'Ü'],
|
126
|
+
['Ý', 'Ý', 'Ý'],
|
127
|
+
['Þ', 'Þ', 'Þ'],
|
128
|
+
['ß', 'ß', 'ß'],
|
129
|
+
['à', 'à', 'à'],
|
130
|
+
['á', 'á', 'á'],
|
131
|
+
['â', 'â', 'â'],
|
132
|
+
['ã', 'ã', 'ã'],
|
133
|
+
['ä', 'ä', 'ä'],
|
134
|
+
['å', 'å', 'å'],
|
135
|
+
['æ', 'æ', 'æ'],
|
136
|
+
['ç', 'ç', 'ç'],
|
137
|
+
['è', 'è', 'è'],
|
138
|
+
['é', 'é', 'é'],
|
139
|
+
['ê', 'ê', 'ê'],
|
140
|
+
['ë', 'ë', 'ë'],
|
141
|
+
['ì', 'ì', 'ì'],
|
142
|
+
['í', 'í', 'í'],
|
143
|
+
['î', 'î', 'î'],
|
144
|
+
['ï', 'ï', 'ï'],
|
145
|
+
['ð', 'ð', 'ð'],
|
146
|
+
['ñ', 'ñ', 'ñ'],
|
147
|
+
['ò', 'ò', 'ò'],
|
148
|
+
['ó', 'ó', 'ó'],
|
149
|
+
['ô', 'ô', 'ô'],
|
150
|
+
['õ', 'õ', 'õ'],
|
151
|
+
['ö', 'ö', 'ö'],
|
152
|
+
['ø', 'ø', 'ø'],
|
153
|
+
['ù', 'ù', 'ù'],
|
154
|
+
['ú', 'ú', 'ú'],
|
155
|
+
['û', 'û', 'û'],
|
156
|
+
['ü', 'ü', 'ü'],
|
157
|
+
['ý', 'ý', 'ý'],
|
158
|
+
['þ', 'þ', 'þ'],
|
159
|
+
['ÿ', 'ÿ', 'ÿ'],
|
160
|
+
[' ', ' ', ' '],
|
161
|
+
['¡', '¡', '¡'],
|
162
|
+
['¢', '¢', '¢'],
|
163
|
+
['£', '£', '£'],
|
164
|
+
['¤', '¤', '¤'],
|
165
|
+
['¥', '¥', '¥'],
|
166
|
+
['¦', '¦', '¦'],
|
167
|
+
['§', '§', '§'],
|
168
|
+
['¨', '¨', '¨'],
|
169
|
+
['©', '©', '©'],
|
170
|
+
['ª', 'ª', 'ª'],
|
171
|
+
['«', '«', '«'],
|
172
|
+
['¬', '¬', '¬'],
|
173
|
+
# ­ ­
|
174
|
+
['®', '®', '®'],
|
175
|
+
['¯', '¯', '¯'],
|
176
|
+
['°', '°', '°'],
|
177
|
+
['±', '±', '±'],
|
178
|
+
['²', '²', '²'],
|
179
|
+
['³', '³', '³'],
|
180
|
+
['´', '´', '´'],
|
181
|
+
['µ', 'µ', 'µ'],
|
182
|
+
['¶', '¶', '¶'],
|
183
|
+
['¸', '¸', '¸'],
|
184
|
+
['¹', '¹', '¹'],
|
185
|
+
['º', 'º', 'º'],
|
186
|
+
['»', '»', '»'],
|
187
|
+
['¼', '¼', '¼'],
|
188
|
+
['½', '½', '½'],
|
189
|
+
['¾', '¾', '¾'],
|
190
|
+
['¿', '¿', '¿'],
|
191
|
+
['×', '×', '×'],
|
192
|
+
['÷', '÷', '÷'],
|
193
|
+
['∀', '∀', '∀'],
|
194
|
+
['∂', '∂', '∂'],
|
195
|
+
['∃', '∃', '∃'],
|
196
|
+
['∅', '∅', '∅'],
|
197
|
+
['∇', '∇', '∇'],
|
198
|
+
['∈', '∈', '∈'],
|
199
|
+
['∉', '∉', '∉'],
|
200
|
+
['∋', '∋', '∋'],
|
201
|
+
['∏', '∏', '∏'],
|
202
|
+
['∑', '∑', '∑'],
|
203
|
+
['−', '−', '−'],
|
204
|
+
['∗', '∗', '∗'],
|
205
|
+
['√', '√', '√'],
|
206
|
+
['∝', '∝', '∝'],
|
207
|
+
['∞', '∞', '∞'],
|
208
|
+
['∠', '∠', '∠'],
|
209
|
+
['∧', '∧', '∧'],
|
210
|
+
['∨', '∨', '∨'],
|
211
|
+
['∩', '∩', '∩'],
|
212
|
+
['∪', '∪', '∪'],
|
213
|
+
['∫', '∫', '∫'],
|
214
|
+
['∴', '∴', '∴'],
|
215
|
+
['∼', '∼', '∼'],
|
216
|
+
['≅', '≅', '≅'],
|
217
|
+
['≈', '≈', '≈'],
|
218
|
+
['≠', '≠', '≠'],
|
219
|
+
['≡', '≡', '≡'],
|
220
|
+
['≤', '≤', '≤'],
|
221
|
+
['≥', '≥', '≥'],
|
222
|
+
['⊂', '⊂', '⊂'],
|
223
|
+
['⊃', '⊃', '⊃'],
|
224
|
+
['⊄', '⊄', '⊄'],
|
225
|
+
['⊆', '⊆', '⊆'],
|
226
|
+
['⊇', '⊇', '⊇'],
|
227
|
+
['⊕', '⊕', '⊕'],
|
228
|
+
['⊗', '⊗', '⊗'],
|
229
|
+
['⊥', '⊥', '⊥'],
|
230
|
+
['⋅', '⋅', '⋅'],
|
231
|
+
['Α', 'Α', 'Α'],
|
232
|
+
['Β', 'Β', 'Β'],
|
233
|
+
['Γ', 'Γ', 'Γ'],
|
234
|
+
['Δ', 'Δ', 'Δ'],
|
235
|
+
['Ε', 'Ε', 'Ε'],
|
236
|
+
['Ζ', 'Ζ', 'Ζ'],
|
237
|
+
['Η', 'Η', 'Η'],
|
238
|
+
['Θ', 'Θ', 'Θ'],
|
239
|
+
['Ι', 'Ι', 'Ι'],
|
240
|
+
['Κ', 'Κ', 'Κ'],
|
241
|
+
['Λ', 'Λ', 'Λ'],
|
242
|
+
['Μ', 'Μ', 'Μ'],
|
243
|
+
['Ν', 'Ν', 'Ν'],
|
244
|
+
['Ξ', 'Ξ', 'Ξ'],
|
245
|
+
['Ο', 'Ο', 'Ο'],
|
246
|
+
['Π', 'Π', 'Π'],
|
247
|
+
['Ρ', 'Ρ', 'Ρ'],
|
248
|
+
['Σ', 'Σ', 'Σ'],
|
249
|
+
['Τ', 'Τ', 'Τ'],
|
250
|
+
['Υ', 'Υ', 'Υ'],
|
251
|
+
['Φ', 'Φ', 'Φ'],
|
252
|
+
['Χ', 'Χ', 'Χ'],
|
253
|
+
['Ψ', 'Ψ', 'Ψ'],
|
254
|
+
['Ω', 'Ω', 'Ω'],
|
255
|
+
['α', 'α', 'α'],
|
256
|
+
['β', 'β', 'β'],
|
257
|
+
['γ', 'γ', 'γ'],
|
258
|
+
['δ', 'δ', 'δ'],
|
259
|
+
['ε', 'ε', 'ε'],
|
260
|
+
['ζ', 'ζ', 'ζ'],
|
261
|
+
['η', 'η', 'η'],
|
262
|
+
['θ', 'θ', 'θ'],
|
263
|
+
['ι', 'ι', 'ι'],
|
264
|
+
['κ', 'κ', 'κ'],
|
265
|
+
['λ', 'λ', 'λ'],
|
266
|
+
['μ', 'μ', 'μ'],
|
267
|
+
['ν', 'ν', 'ν'],
|
268
|
+
['ξ', 'ξ', 'ξ'],
|
269
|
+
['ο', 'ο', 'ο'],
|
270
|
+
['π', 'π', 'π'],
|
271
|
+
['ρ', 'ρ', 'ρ'],
|
272
|
+
['ς', 'ς', 'ς'],
|
273
|
+
['σ', 'σ', 'σ'],
|
274
|
+
['σ', 'σ', 'σ'],
|
275
|
+
['τ', 'τ', 'τ'],
|
276
|
+
['υ', 'υ', 'υ'],
|
277
|
+
['φ', 'φ', 'φ'],
|
278
|
+
['χ', 'χ', 'χ'],
|
279
|
+
['ψ', 'ψ', 'ψ'],
|
280
|
+
['ω', 'ω', 'ω'],
|
281
|
+
['ϑ', 'ϑ', 'ϑ'],
|
282
|
+
['ϒ', 'ϒ', 'ϒ'],
|
283
|
+
['ϖ', 'ϖ', 'ϖ'],
|
284
|
+
['Œ', 'Œ', 'Œ'],
|
285
|
+
['œ', 'œ', 'œ'],
|
286
|
+
['Š', 'Š', 'Š'],
|
287
|
+
['š', 'š', 'š'],
|
288
|
+
['Ÿ', 'Ÿ', 'Ÿ'],
|
289
|
+
['ƒ', 'ƒ', 'ƒ'],
|
290
|
+
['ˆ', 'ˆ', 'ˆ'],
|
291
|
+
['˜', '˜', '˜'],
|
292
|
+
[' ', ' ', ' '],
|
293
|
+
[' ', ' ', ' '],
|
294
|
+
[' ', ' ', ' '],
|
295
|
+
['', '‌', '‌'],
|
296
|
+
['', '‍', '‍'],
|
297
|
+
['', '‎', '‎'],
|
298
|
+
['', '‏', '‏'],
|
299
|
+
['–', '–', '–'],
|
300
|
+
['—', '—', '—'],
|
301
|
+
['‘', '‘', '‘'],
|
302
|
+
['’', '’', '’'],
|
303
|
+
['‚', '‚', '‚'],
|
304
|
+
['“', '“', '“'],
|
305
|
+
['”', '”', '”'],
|
306
|
+
['„', '„', '„'],
|
307
|
+
['†', '†', '†'],
|
308
|
+
['‡', '‡', '‡'],
|
309
|
+
['•', '•', '•'],
|
310
|
+
['…', '…', '…'],
|
311
|
+
['‰', '‰', '‰'],
|
312
|
+
['′', '′', '′'],
|
313
|
+
['″', '″', '″'],
|
314
|
+
['‹', '‹', '‹'],
|
315
|
+
['›', '›', '‹'],
|
316
|
+
['‾', '‾', '‾'],
|
317
|
+
['€', '€', '€'],
|
318
|
+
['™', '™', '™'],
|
319
|
+
['←', '←', '←'],
|
320
|
+
['↑', '↑', '↑'],
|
321
|
+
['→', '→', '→'],
|
322
|
+
['↓', '↓', '↓'],
|
323
|
+
['↔', '↔', '↔'],
|
324
|
+
['↵', '↵', '↵'],
|
325
|
+
['⌈', '⌈', '⌈'],
|
326
|
+
['⌉', '⌉', '⌉'],
|
327
|
+
['⌊', '⌊', '⌊'],
|
328
|
+
['⌋', '⌋', '⌋'],
|
329
|
+
['◊', '◊', '◊'],
|
330
|
+
['♠', '♠', '♠'],
|
331
|
+
['♣', '♣', '♣'],
|
332
|
+
['♥', '♥', '♥'],
|
333
|
+
['♦', '♦', '♦']]
|
334
|
+
|
335
|
+
def self.encode_entities(str)
|
336
|
+
str.gsub /([^[:ascii:]]|&)/ do|match|
|
337
|
+
arr = HTML_ENTITIES.select { |arr| arr[0]==match }.first
|
338
|
+
if arr
|
339
|
+
arr[1].empty? ? arr[2] : arr[1]
|
340
|
+
else
|
341
|
+
match
|
342
|
+
end
|
343
|
+
end
|
344
|
+
end
|
345
|
+
|
346
|
+
def self.decode_entities(str)
|
347
|
+
str.gsub /&.*?;/ do |match|
|
348
|
+
arr = HTML_ENTITIES.select { |arr| arr[1]==match || arr[2]==match }.first
|
349
|
+
if arr
|
350
|
+
arr[0]
|
351
|
+
else
|
352
|
+
match
|
353
|
+
end
|
354
|
+
end
|
355
|
+
end
|
356
|
+
end
|
357
|
+
end
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: htmlentity_translator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rodrigo Urubatan
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-05-27 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: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: This gem is a simple libraty to help add or remoge HTML entities to a
|
42
|
+
string the usage is simple "&this needs to be removedá".decode_entities
|
43
|
+
will remove all HTML entities, and "á now I need it encoded".encode_entities will
|
44
|
+
replace non printable ascii with the corresponding HTML entitites
|
45
|
+
email:
|
46
|
+
- rodrigo@urubatan.com.br
|
47
|
+
executables: []
|
48
|
+
extensions: []
|
49
|
+
extra_rdoc_files: []
|
50
|
+
files:
|
51
|
+
- ".gitignore"
|
52
|
+
- Gemfile
|
53
|
+
- LICENSE.txt
|
54
|
+
- README.md
|
55
|
+
- Rakefile
|
56
|
+
- htmlentity_translator.gemspec
|
57
|
+
- htmlentity_translator.iml
|
58
|
+
- lib/htmlentity_translator.rb
|
59
|
+
- lib/htmlentity_translator/entity_maper.rb
|
60
|
+
- lib/htmlentity_translator/string_instrument.rb
|
61
|
+
- lib/htmlentity_translator/version.rb
|
62
|
+
homepage: ''
|
63
|
+
licenses:
|
64
|
+
- MIT
|
65
|
+
metadata: {}
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements: []
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 2.2.2
|
83
|
+
signing_key:
|
84
|
+
specification_version: 4
|
85
|
+
summary: This gem is a simple library to help add or remove HTML entities to a string
|
86
|
+
test_files: []
|