htmlentity_translator 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in htmlentity_translator.gemspec
4
+ gemspec
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,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -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,6 @@
1
+ require "htmlentity_translator/version"
2
+ require "htmlentity_translator/entity_maper"
3
+ require "htmlentity_translator/string_instrument"
4
+ module HtmlentityTranslator
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,357 @@
1
+ module HtmlentityTranslator
2
+ module EntityMaper
3
+ HTML_ENTITIES =[[' ', '&nbsp;', '&#32;'],
4
+ ['!', '', '&#33;'],
5
+ ['"', '', '&#34;'],
6
+ ['#', '', '&#35;'],
7
+ ['$', '', '&#36;'],
8
+ ['%', '', '&#37;'],
9
+ ['&', '&amp;', '&#38;'],
10
+ ["'", '', '&#39;'],
11
+ ['(', '', '&#40;'],
12
+ [')', '', '&#41;'],
13
+ ['*', '', '&#42;'],
14
+ ['+', '', '&#43;'],
15
+ [',', '', '&#44;'],
16
+ ['-', '', '&#45;'],
17
+ ['.', '', '&#46;'],
18
+ ['/', '', '&#47;'],
19
+ ['0', '', '&#48;'],
20
+ ['1', '', '&#49;'],
21
+ ['2', '', '&#50;'],
22
+ ['3', '', '&#51;'],
23
+ ['4', '', '&#52;'],
24
+ ['5', '', '&#53;'],
25
+ ['6', '', '&#54;'],
26
+ ['7', '', '&#55;'],
27
+ ['8', '', '&#56;'],
28
+ ['9', '', '&#57;'],
29
+ [':', '', '&#58;'],
30
+ [';', '', '&#59;'],
31
+ ['<', '&lt;', '&#60;'],
32
+ ['=', '', '&#61;'],
33
+ ['>', '&gt;', '&#62;'],
34
+ ['?', '', '&#63;'],
35
+ ['@', '', '&#64;'],
36
+ ['A', '', '&#65;'],
37
+ ['B', '', '&#66;'],
38
+ ['C', '', '&#67;'],
39
+ ['D', '', '&#68;'],
40
+ ['E', '', '&#69;'],
41
+ ['F', '', '&#70;'],
42
+ ['G', '', '&#71;'],
43
+ ['H', '', '&#72;'],
44
+ ['I', '', '&#73;'],
45
+ ['J', '', '&#74;'],
46
+ ['K', '', '&#75;'],
47
+ ['L', '', '&#76;'],
48
+ ['M', '', '&#77;'],
49
+ ['N', '', '&#78;'],
50
+ ['O', '', '&#79;'],
51
+ ['P', '', '&#80;'],
52
+ ['Q', '', '&#81;'],
53
+ ['R', '', '&#82;'],
54
+ ['S', '', '&#83;'],
55
+ ['T', '', '&#84;'],
56
+ ['U', '', '&#85;'],
57
+ ['V', '', '&#86;'],
58
+ ['W', '', '&#87;'],
59
+ ['X', '', '&#88;'],
60
+ ['Y', '', '&#89;'],
61
+ ['Z', '', '&#90;'],
62
+ ['[', '', '&#91;'],
63
+ ["\\", '', '&#92;'],
64
+ [']', '', '&#93;'],
65
+ ['^', '', '&#94;'],
66
+ ['_', '', '&#95;'],
67
+ ['`', '', '&#96;'],
68
+ ['a', '', '&#97;'],
69
+ ['b', '', '&#98;'],
70
+ ['c', '', '&#99;'],
71
+ ['d', '', '&#100;'],
72
+ ['e', '', '&#101;'],
73
+ ['f', '', '&#102;'],
74
+ ['g', '', '&#103;'],
75
+ ['h', '', '&#104;'],
76
+ ['i', '', '&#105;'],
77
+ ['j', '', '&#106;'],
78
+ ['k', '', '&#107;'],
79
+ ['l', '', '&#108;'],
80
+ ['m', '', '&#109;'],
81
+ ['n', '', '&#110;'],
82
+ ['o', '', '&#111;'],
83
+ ['p', '', '&#112;'],
84
+ ['q', '', '&#113;'],
85
+ ['r', '', '&#114;'],
86
+ ['s', '', '&#115;'],
87
+ ['t', '', '&#116;'],
88
+ ['u', '', '&#117;'],
89
+ ['v', '', '&#118;'],
90
+ ['w', '', '&#119;'],
91
+ ['x', '', '&#120;'],
92
+ ['y', '', '&#121;'],
93
+ ['z', '', '&#122;'],
94
+ ['{', '', '&#123;'],
95
+ ['|', '', '&#124;'],
96
+ ['}', '', '&#125;'],
97
+ ['~', '', '&#126;'],
98
+ ['À', '&Agrave;', '&#192;'],
99
+ ['Á', '&Aacute;', '&#193;'],
100
+ ['Â', '&Acirc;', '&#194;'],
101
+ ['Ã', '&Atilde;', '&#195;'],
102
+ ['Ä', '&Auml;', '&#196;'],
103
+ ['Å', '&Aring;', '&#197;'],
104
+ ['Æ', '&AElig;', '&#198;'],
105
+ ['Ç', '&Ccedil;', '&#199;'],
106
+ ['È', '&Egrave;', '&#200;'],
107
+ ['É', '&Eacute;', '&#201;'],
108
+ # &Ecirc; &#202;
109
+ ['Ë', '&Euml;', '&#203;'],
110
+ ['Ì', '&Igrave;', '&#204;'],
111
+ ['Í', '&Iacute;', '&#205;'],
112
+ ['Î', '&Icirc;', '&#206;'],
113
+ ['Ï', '&Iuml;', '&#207;'],
114
+ ['Ð', '&ETH;', '&#208;'],
115
+ ['Ñ', '&Ntilde;', '&#209;'],
116
+ ['Ò', '&Ograve;', '&#210;'],
117
+ ['Ó', '&Oacute;', '&#211;'],
118
+ ['Ô', '&Ocirc;', '&#212;'],
119
+ ['Õ', '&Otilde;', '&#213;'],
120
+ ['Ö', '&Ouml;', '&#214;'],
121
+ ['Ø', '&Oslash;', '&#216;'],
122
+ ['Ù', '&Ugrave;', '&#217;'],
123
+ ['Ú', '&Uacute;', '&#218;'],
124
+ ['Û', '&Ucirc;', '&#219;'],
125
+ ['Ü', '&Uuml;', '&#220;'],
126
+ ['Ý', '&Yacute;', '&#221;'],
127
+ ['Þ', '&THORN;', '&#222;'],
128
+ ['ß', '&szlig;', '&#223;'],
129
+ ['à', '&agrave;', '&#224;'],
130
+ ['á', '&aacute;', '&#225;'],
131
+ ['â', '&acirc;', '&#226;'],
132
+ ['ã', '&atilde;', '&#227;'],
133
+ ['ä', '&auml;', '&#228;'],
134
+ ['å', '&aring;', '&#229;'],
135
+ ['æ', '&aelig;', '&#230;'],
136
+ ['ç', '&ccedil;', '&#231;'],
137
+ ['è', '&egrave;', '&#232;'],
138
+ ['é', '&eacute;', '&#233;'],
139
+ ['ê', '&ecirc;', '&#234;'],
140
+ ['ë', '&euml;', '&#235;'],
141
+ ['ì', '&igrave;', '&#236;'],
142
+ ['í', '&iacute;', '&#237;'],
143
+ ['î', '&icirc;', '&#238;'],
144
+ ['ï', '&iuml;', '&#239;'],
145
+ ['ð', '&eth;', '&#240;'],
146
+ ['ñ', '&ntilde;', '&#241;'],
147
+ ['ò', '&ograve;', '&#242;'],
148
+ ['ó', '&oacute;', '&#243;'],
149
+ ['ô', '&ocirc;', '&#244;'],
150
+ ['õ', '&otilde;', '&#245;'],
151
+ ['ö', '&ouml;', '&#246;'],
152
+ ['ø', '&oslash;', '&#248;'],
153
+ ['ù', '&ugrave;', '&#249;'],
154
+ ['ú', '&uacute;', '&#250;'],
155
+ ['û', '&ucirc;', '&#251;'],
156
+ ['ü', '&uuml;', '&#252;'],
157
+ ['ý', '&yacute;', '&#253;'],
158
+ ['þ', '&thorn;', '&#254;'],
159
+ ['ÿ', '&yuml;', '&#255;'],
160
+ [' ', '&nbsp;', '&#160;'],
161
+ ['¡', '&iexcl;', '&#161;'],
162
+ ['¢', '&cent;', '&#162;'],
163
+ ['£', '&pound;', '&#163;'],
164
+ ['¤', '&curren;', '&#164;'],
165
+ ['¥', '&yen;', '&#165;'],
166
+ ['¦', '&brvbar;', '&#166;'],
167
+ ['§', '&sect;', '&#167;'],
168
+ ['¨', '&uml;', '&#168;'],
169
+ ['©', '&copy;', '&#169;'],
170
+ ['ª', '&ordf;', '&#170;'],
171
+ ['«', '&laquo;', '&#171;'],
172
+ ['¬', '&not;', '&#172;'],
173
+ # &shy; &#173;
174
+ ['®', '&reg;', '&#174;'],
175
+ ['¯', '&macr;', '&#175;'],
176
+ ['°', '&deg;', '&#176;'],
177
+ ['±', '&plusmn;', '&#177;'],
178
+ ['²', '&sup2;', '&#178;'],
179
+ ['³', '&sup3;', '&#179;'],
180
+ ['´', '&acute;', '&#180;'],
181
+ ['µ', '&micro;', '&#181;'],
182
+ ['¶', '&para;', '&#182;'],
183
+ ['¸', '&cedil;', '&#184;'],
184
+ ['¹', '&sup1;', '&#185;'],
185
+ ['º', '&ordm;', '&#186;'],
186
+ ['»', '&raquo;', '&#187;'],
187
+ ['¼', '&frac14;', '&#188;'],
188
+ ['½', '&frac12;', '&#189;'],
189
+ ['¾', '&frac34;', '&#190;'],
190
+ ['¿', '&iquest;', '&#191;'],
191
+ ['×', '&times;', '&#215;'],
192
+ ['÷', '&divide;', '&#247;'],
193
+ ['∀', '&forall;', '&#8704;'],
194
+ ['∂', '&part;', '&#8706;'],
195
+ ['∃', '&exist;', '&#8707;'],
196
+ ['∅', '&empty;', '&#8709;'],
197
+ ['∇', '&nabla;', '&#8711;'],
198
+ ['∈', '&isin;', '&#8712;'],
199
+ ['∉', '&notin;', '&#8713;'],
200
+ ['∋', '&ni;', '&#8715;'],
201
+ ['∏', '&prod;', '&#8719;'],
202
+ ['∑', '&sum;', '&#8721;'],
203
+ ['−', '&minus;', '&#8722;'],
204
+ ['∗', '&lowast;', '&#8727;'],
205
+ ['√', '&radic;', '&#8730;'],
206
+ ['∝', '&prop;', '&#8733;'],
207
+ ['∞', '&infin;', '&#8734;'],
208
+ ['∠', '&ang;', '&#8736;'],
209
+ ['∧', '&and;', '&#8743;'],
210
+ ['∨', '&or;', '&#8744;'],
211
+ ['∩', '&cap;', '&#8745;'],
212
+ ['∪', '&cup;', '&#8746;'],
213
+ ['∫', '&int;', '&#8747;'],
214
+ ['∴', '&there4;', '&#8756;'],
215
+ ['∼', '&sim;', '&#8764;'],
216
+ ['≅', '&cong;', '&#8773;'],
217
+ ['≈', '&asymp;', '&#8776;'],
218
+ ['≠', '&ne;', '&#8800;'],
219
+ ['≡', '&equiv;', '&#8801;'],
220
+ ['≤', '&le;', '&#8804;'],
221
+ ['≥', '&ge;', '&#8805;'],
222
+ ['⊂', '&sub;', '&#8834;'],
223
+ ['⊃', '&sup;', '&#8835;'],
224
+ ['⊄', '&nsub;', '&#8836;'],
225
+ ['⊆', '&sube;', '&#8838;'],
226
+ ['⊇', '&supe;', '&#8839;'],
227
+ ['⊕', '&oplus;', '&#8853;'],
228
+ ['⊗', '&otimes;', '&#8855;'],
229
+ ['⊥', '&perp;', '&#8869;'],
230
+ ['⋅', '&sdot;', '&#8901;'],
231
+ ['Α', '&Alpha;', '&#913;'],
232
+ ['Β', '&Beta;', '&#914;'],
233
+ ['Γ', '&Gamma;', '&#915;'],
234
+ ['Δ', '&Delta;', '&#916;'],
235
+ ['Ε', '&Epsilon;', '&#917;'],
236
+ ['Ζ', '&Zeta;', '&#918;'],
237
+ ['Η', '&Eta;', '&#919;'],
238
+ ['Θ', '&Theta;', '&#920;'],
239
+ ['Ι', '&Iota;', '&#921;'],
240
+ ['Κ', '&Kappa;', '&#922;'],
241
+ ['Λ', '&Lambda;', '&#923;'],
242
+ ['Μ', '&Mu;', '&#924;'],
243
+ ['Ν', '&Nu;', '&#925;'],
244
+ ['Ξ', '&Xi;', '&#926;'],
245
+ ['Ο', '&Omicron;', '&#927;'],
246
+ ['Π', '&Pi;', '&#928;'],
247
+ ['Ρ', '&Rho;', '&#929;'],
248
+ ['Σ', '&Sigma;', '&#931;'],
249
+ ['Τ', '&Tau;', '&#932;'],
250
+ ['Υ', '&Upsilon;', '&#933;'],
251
+ ['Φ', '&Phi;', '&#934;'],
252
+ ['Χ', '&Chi;', '&#935;'],
253
+ ['Ψ', '&Psi;', '&#936;'],
254
+ ['Ω', '&Omega;', '&#937;'],
255
+ ['α', '&alpha;', '&#945;'],
256
+ ['β', '&beta;', '&#946;'],
257
+ ['γ', '&gamma;', '&#947;'],
258
+ ['δ', '&delta;', '&#948;'],
259
+ ['ε', '&epsilon;', '&#949;'],
260
+ ['ζ', '&zeta;', '&#950;'],
261
+ ['η', '&eta;', '&#951;'],
262
+ ['θ', '&theta;', '&#952;'],
263
+ ['ι', '&iota;', '&#953;'],
264
+ ['κ', '&kappa;', '&#954;'],
265
+ ['λ', '&lambda;', '&#955;'],
266
+ ['μ', '&mu;', '&#956;'],
267
+ ['ν', '&nu;', '&#957;'],
268
+ ['ξ', '&xi;', '&#958;'],
269
+ ['ο', '&omicron;', '&#959;'],
270
+ ['π', '&pi;', '&#960;'],
271
+ ['ρ', '&rho;', '&#961;'],
272
+ ['ς', '&sigmaf;', '&#962;'],
273
+ ['σ', '&sigma;', '&#963;'],
274
+ ['σ', '&sigma;', '&#963;'],
275
+ ['τ', '&tau;', '&#964;'],
276
+ ['υ', '&upsilon;', '&#965;'],
277
+ ['φ', '&phi;', '&#966;'],
278
+ ['χ', '&chi;', '&#967;'],
279
+ ['ψ', '&psi;', '&#968;'],
280
+ ['ω', '&omega;', '&#969;'],
281
+ ['ϑ', '&thetasym;', '&#977;'],
282
+ ['ϒ', '&upsih;', '&#978;'],
283
+ ['ϖ', '&piv;', '&#982;'],
284
+ ['Œ', '&OElig;', '&#338;'],
285
+ ['œ', '&oelig;', '&#339;'],
286
+ ['Š', '&Scaron;', '&#352;'],
287
+ ['š', '&scaron;', '&#353;'],
288
+ ['Ÿ', '&Yuml;', '&#376;'],
289
+ ['ƒ', '&fnof;', '&#402;'],
290
+ ['ˆ', '&circ;', '&#710;'],
291
+ ['˜', '&tilde;', '&#732;'],
292
+ [' ', '&ensp;', '&#8194;'],
293
+ [' ', '&emsp;', '&#8195;'],
294
+ [' ', '&thinsp;', '&#8201;'],
295
+ ['‌', '&zwnj;', '&#8204;'],
296
+ ['‍', '&zwj;', '&#8205;'],
297
+ ['‎', '&lrm;', '&#8206;'],
298
+ ['‏', '&rlm;', '&#8207;'],
299
+ ['–', '&ndash;', '&#8211;'],
300
+ ['—', '&mdash;', '&#8212;'],
301
+ ['‘', '&lsquo;', '&#8216;'],
302
+ ['’', '&rsquo;', '&#8217;'],
303
+ ['‚', '&sbquo;', '&#8218;'],
304
+ ['“', '&ldquo;', '&#8220;'],
305
+ ['”', '&rdquo;', '&#8221;'],
306
+ ['„', '&bdquo;', '&#8222;'],
307
+ ['†', '&dagger;', '&#8224;'],
308
+ ['‡', '&Dagger;', '&#8225;'],
309
+ ['•', '&bull;', '&#8226;'],
310
+ ['…', '&hellip;', '&#8230;'],
311
+ ['‰', '&permil;', '&#8240;'],
312
+ ['′', '&prime;', '&#8242;'],
313
+ ['″', '&Prime;', '&#8243;'],
314
+ ['‹', '&lsaquo;', '&#8249;'],
315
+ ['›', '&rsaquo;', '&#8249;'],
316
+ ['‾', '&oline;', '&#8254;'],
317
+ ['€', '&euro;', '&#8364;'],
318
+ ['™', '&trade;', '&#8482;'],
319
+ ['←', '&larr;', '&#8592;'],
320
+ ['↑', '&uarr;', '&#8593;'],
321
+ ['→', '&rarr;', '&#8594;'],
322
+ ['↓', '&darr;', '&#8595;'],
323
+ ['↔', '&harr;', '&#8596;'],
324
+ ['↵', '&crarr;', '&#8629;'],
325
+ ['⌈', '&lceil;', '&#8968;'],
326
+ ['⌉', '&rceil;', '&#8969;'],
327
+ ['⌊', '&lfloor;', '&#8970;'],
328
+ ['⌋', '&rfloor;', '&#8971;'],
329
+ ['◊', '&loz;', '&#9674;'],
330
+ ['♠', '&spades;', '&#9824;'],
331
+ ['♣', '&clubs;', '&#9827;'],
332
+ ['♥', '&hearts;', '&#9829;'],
333
+ ['♦', '&diams;', '&#9830;']]
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
@@ -0,0 +1,8 @@
1
+ class ::String
2
+ def decode_entities
3
+ HtmlentityTranslator::EntityMaper.decode_entities(self)
4
+ end
5
+ def encode_entities
6
+ HtmlentityTranslator::EntityMaper.encode_entities(self)
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ module HtmlentityTranslator
2
+ VERSION = "0.0.1"
3
+ 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 "&amp;this needs to be removed&aacute;".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: []