nokogumbo 1.4.3 → 1.4.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2ea9a9bee29cbf479c7afab79a4df38040ed60e7
4
- data.tar.gz: f7e87af169388de1f0b32fd457e73182169bc503
3
+ metadata.gz: c9b785e621546a6250bcaa6b2c538a5d5fd73c4f
4
+ data.tar.gz: 99b2f45bd6178ad0b1d4b4f249884e849f296fbe
5
5
  SHA512:
6
- metadata.gz: 6413991d638e6bacc465442546c7ca7756fb0cd8f577ccb9b65d60da87c009b7b2d212bb3fe928b7bbde97ba66f9180d8c5e3efdd02648e33e5d7546b452476f
7
- data.tar.gz: 4a3486ed36ab147b828e9f79244c36a2d33b2a8dccc61fa8d6abf75556ebb76313c7d009c2502bc3142e38644759c1e6c6bab5d1c1b21b346bf16702802650e4
6
+ metadata.gz: d6fa6e1dee3a419cde35d11d64cd61d4fdcb0e0ab594810a110b92b7ad8ce9afc52b40e7555c5e7334e42a70b55d72a461c791a8d5ec0c0815a48ba7c3cdce62
7
+ data.tar.gz: 0beec6b9664eead77d4a86e0775811d84f0dccf472e262f32f1202b5a1fb70de9a8a80070b938ac933c62bf74537eeb1fec93a6a48a90497bb7bd0b0927d3b53
data/README.md CHANGED
@@ -39,6 +39,12 @@ require 'nokogumbo'
39
39
  puts Nokogiri::HTML5.get('http://nokogiri.org').search('ol li')[2].text
40
40
  ```
41
41
 
42
+ Use `.to_html` instead of `.to_s` when parsing and serializing multiple times
43
+ ```
44
+ require 'nokogumbo'
45
+ Nokogiri::HTML5.parse(Nokogiri::HTML5.parse('<div></div> a').to_html).to_html
46
+ ```
47
+
42
48
  Notes
43
49
  -----
44
50
 
@@ -157,7 +157,7 @@ static xmlNodePtr walk_tree(xmlDocPtr document, GumboElement *node) {
157
157
 
158
158
  switch (child->type) {
159
159
  case GUMBO_NODE_ELEMENT:
160
- // case GUMBO_NODE_TEMPLATE: /* future */
160
+ case GUMBO_NODE_TEMPLATE:
161
161
  node = walk_tree(document, &child->v.element);
162
162
  break;
163
163
  case GUMBO_NODE_WHITESPACE:
@@ -189,6 +189,7 @@ static VALUE parse(VALUE self, VALUE string) {
189
189
  (size_t) RSTRING_LEN(string)
190
190
  );
191
191
  xmlDocPtr doc = xmlNewDoc(CONST_CAST "1.0");
192
+ doc->type = XML_HTML_DOCUMENT_NODE;
192
193
  xmlNodePtr root = walk_tree(doc, &output->root->v.element);
193
194
  xmlDocSetRootElement(doc, root);
194
195
  if (output->document->v.document.has_doctype) {
data/test-nokogumbo.rb CHANGED
@@ -12,11 +12,17 @@ class TestNokogumbo < Minitest::Test
12
12
  assert_equal "content", doc.at('span').text
13
13
  end
14
14
 
15
- def test_element_cdata
15
+ def test_element_cdata_textarea
16
16
  doc = Nokogiri::HTML5(buffer)
17
17
  assert_equal "foo<x>bar", doc.at('textarea').text.strip
18
18
  end
19
19
 
20
+ def test_element_cdata_script
21
+ doc = Nokogiri::HTML5.fragment(buffer)
22
+ assert_equal true, doc.document.html?
23
+ assert_equal "<script> if (a < b) alert(1) </script>", doc.at('script').to_s
24
+ end
25
+
20
26
  def test_attr_value
21
27
  doc = Nokogiri::HTML5(buffer)
22
28
  assert_equal "utf-8", doc.at('meta')['charset']
@@ -99,7 +105,7 @@ class TestNokogumbo < Minitest::Test
99
105
  assert_equal ["xlink:href", "xmlns:xlink"], a.attributes.keys.sort
100
106
  end
101
107
 
102
- def x_test_template # future
108
+ def test_template
103
109
  source = <<-EOF.gsub(/^ {6}/, '')
104
110
  <template id="productrow">
105
111
  <tr>
@@ -122,6 +128,7 @@ private
122
128
  <head>
123
129
  <meta charset="utf-8"/>
124
130
  <title>hello world</title>
131
+ <script> if (a < b) alert(1) </script>
125
132
  </head>
126
133
  <body>
127
134
  <h1>hello world</h1>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nokogumbo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.3
4
+ version: 1.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Ruby
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-23 00:00:00.000000000 Z
11
+ date: 2015-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri