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 +4 -4
- data/README.md +6 -0
- data/ext/nokogumboc/nokogumbo.c +2 -1
- data/test-nokogumbo.rb +9 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9b785e621546a6250bcaa6b2c538a5d5fd73c4f
|
4
|
+
data.tar.gz: 99b2f45bd6178ad0b1d4b4f249884e849f296fbe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
|
data/ext/nokogumboc/nokogumbo.c
CHANGED
@@ -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
|
-
|
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
|
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
|
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.
|
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-
|
11
|
+
date: 2015-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|