htmlentities 4.0.0 → 4.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.
- data/COPYING.txt +1 -1
- data/History.txt +13 -1
- data/README.txt +1 -1
- data/lib/htmlentities.rb +78 -51
- data/lib/htmlentities/flavors.rb +9 -0
- data/lib/htmlentities/legacy.rb +10 -6
- data/lib/htmlentities/mappings/expanded.rb +1050 -0
- data/lib/htmlentities/{html4.rb → mappings/html4.rb} +1 -1
- data/lib/htmlentities/{xhtml1.rb → mappings/xhtml1.rb} +1 -1
- data/lib/htmlentities/version.rb +9 -0
- data/test/entities_test.rb +5 -4
- data/test/expanded_test.rb +112 -0
- data/test/html4_test.rb +8 -3
- data/test/legacy_test.rb +7 -6
- data/test/roundtrip_test.rb +21 -22
- data/test/test_all.rb +2 -1
- data/test/xhtml1_test.rb +8 -2
- metadata +53 -44
- data/lib/htmlentities/string.rb +0 -26
- data/test/string_test.rb +0 -24
data/lib/htmlentities/string.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'htmlentities'
|
2
|
-
|
3
|
-
#
|
4
|
-
# This file extends the String class with methods to allow encoding and decoding of
|
5
|
-
# HTML/XML entities from/to their corresponding UTF-8 codepoints.
|
6
|
-
#
|
7
|
-
class String
|
8
|
-
|
9
|
-
#
|
10
|
-
# Decode XML and HTML 4.01 entities in a string into their UTF-8
|
11
|
-
# equivalents.
|
12
|
-
#
|
13
|
-
def decode_entities
|
14
|
-
return HTMLEntities.decode_entities(self)
|
15
|
-
end
|
16
|
-
|
17
|
-
#
|
18
|
-
# Encode codepoints in a string into their corresponding entities. See
|
19
|
-
# the documentation of HTMLEntities.encode_entities for a list of possible
|
20
|
-
# instructions.
|
21
|
-
#
|
22
|
-
def encode_entities(*instructions)
|
23
|
-
return HTMLEntities.encode_entities(self, *instructions)
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
data/test/string_test.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
2
|
-
require 'htmlentities/string'
|
3
|
-
require 'test/unit'
|
4
|
-
|
5
|
-
$KCODE = 'u'
|
6
|
-
|
7
|
-
class TestHTMLEntities < Test::Unit::TestCase
|
8
|
-
|
9
|
-
def test_string_responds_correctly_to_decode_entities
|
10
|
-
assert_equal('±', '±'.decode_entities)
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_string_responds_correctly_to_encode_entities_with_no_parameters
|
14
|
-
assert_equal('"', '"'.encode_entities)
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_string_responds_correctly_to_encode_entities_with_multiple_parameters
|
18
|
-
assert_equal(
|
19
|
-
'"bientôt" & 文字',
|
20
|
-
'"bientôt" & 文字'.encode_entities(:basic, :named, :hexadecimal)
|
21
|
-
)
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|