tenderlove-nokogiri 0.0.0.20081001111445
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -0
- data/Manifest.txt +105 -0
- data/README.txt +51 -0
- data/Rakefile +70 -0
- data/ext/nokogiri/extconf.rb +24 -0
- data/ext/nokogiri/html_document.c +85 -0
- data/ext/nokogiri/html_document.h +10 -0
- data/ext/nokogiri/html_sax_parser.c +32 -0
- data/ext/nokogiri/html_sax_parser.h +11 -0
- data/ext/nokogiri/native.c +35 -0
- data/ext/nokogiri/native.h +32 -0
- data/ext/nokogiri/xml_cdata.c +36 -0
- data/ext/nokogiri/xml_cdata.h +9 -0
- data/ext/nokogiri/xml_document.c +159 -0
- data/ext/nokogiri/xml_document.h +10 -0
- data/ext/nokogiri/xml_node.c +573 -0
- data/ext/nokogiri/xml_node.h +13 -0
- data/ext/nokogiri/xml_node_set.c +90 -0
- data/ext/nokogiri/xml_node_set.h +9 -0
- data/ext/nokogiri/xml_reader.c +420 -0
- data/ext/nokogiri/xml_reader.h +10 -0
- data/ext/nokogiri/xml_sax_parser.c +161 -0
- data/ext/nokogiri/xml_sax_parser.h +10 -0
- data/ext/nokogiri/xml_text.c +25 -0
- data/ext/nokogiri/xml_text.h +9 -0
- data/ext/nokogiri/xml_xpath.c +39 -0
- data/ext/nokogiri/xml_xpath.h +11 -0
- data/ext/nokogiri/xml_xpath_context.c +69 -0
- data/ext/nokogiri/xml_xpath_context.h +9 -0
- data/ext/nokogiri/xslt_stylesheet.c +83 -0
- data/ext/nokogiri/xslt_stylesheet.h +9 -0
- data/lib/nokogiri.rb +45 -0
- data/lib/nokogiri/css.rb +6 -0
- data/lib/nokogiri/css/node.rb +95 -0
- data/lib/nokogiri/css/parser.rb +24 -0
- data/lib/nokogiri/css/parser.y +198 -0
- data/lib/nokogiri/css/tokenizer.rb +9 -0
- data/lib/nokogiri/css/tokenizer.rex +63 -0
- data/lib/nokogiri/css/xpath_visitor.rb +153 -0
- data/lib/nokogiri/decorators.rb +1 -0
- data/lib/nokogiri/decorators/hpricot.rb +3 -0
- data/lib/nokogiri/decorators/hpricot/node.rb +47 -0
- data/lib/nokogiri/decorators/hpricot/node_set.rb +14 -0
- data/lib/nokogiri/decorators/hpricot/xpath_visitor.rb +13 -0
- data/lib/nokogiri/hpricot.rb +46 -0
- data/lib/nokogiri/html.rb +64 -0
- data/lib/nokogiri/html/builder.rb +9 -0
- data/lib/nokogiri/html/document.rb +9 -0
- data/lib/nokogiri/html/sax/parser.rb +21 -0
- data/lib/nokogiri/version.rb +3 -0
- data/lib/nokogiri/xml.rb +29 -0
- data/lib/nokogiri/xml/after_handler.rb +18 -0
- data/lib/nokogiri/xml/before_handler.rb +32 -0
- data/lib/nokogiri/xml/builder.rb +79 -0
- data/lib/nokogiri/xml/document.rb +22 -0
- data/lib/nokogiri/xml/node.rb +162 -0
- data/lib/nokogiri/xml/node_set.rb +136 -0
- data/lib/nokogiri/xml/reader.rb +14 -0
- data/lib/nokogiri/xml/sax.rb +9 -0
- data/lib/nokogiri/xml/sax/document.rb +59 -0
- data/lib/nokogiri/xml/sax/parser.rb +33 -0
- data/lib/nokogiri/xml/text.rb +6 -0
- data/lib/nokogiri/xml/xpath.rb +6 -0
- data/lib/nokogiri/xslt.rb +11 -0
- data/lib/nokogiri/xslt/stylesheet.rb +6 -0
- data/nokogiri.gemspec +33 -0
- data/test/css/test_nthiness.rb +141 -0
- data/test/css/test_parser.rb +214 -0
- data/test/css/test_tokenizer.rb +162 -0
- data/test/files/staff.xml +57 -0
- data/test/files/staff.xslt +32 -0
- data/test/files/tlm.html +850 -0
- data/test/helper.rb +70 -0
- data/test/hpricot/files/basic.xhtml +17 -0
- data/test/hpricot/files/boingboing.html +2266 -0
- data/test/hpricot/files/cy0.html +3653 -0
- data/test/hpricot/files/immob.html +400 -0
- data/test/hpricot/files/pace_application.html +1320 -0
- data/test/hpricot/files/tenderlove.html +16 -0
- data/test/hpricot/files/uswebgen.html +220 -0
- data/test/hpricot/files/utf8.html +1054 -0
- data/test/hpricot/files/week9.html +1723 -0
- data/test/hpricot/files/why.xml +19 -0
- data/test/hpricot/load_files.rb +7 -0
- data/test/hpricot/test_alter.rb +67 -0
- data/test/hpricot/test_builder.rb +27 -0
- data/test/hpricot/test_parser.rb +412 -0
- data/test/hpricot/test_paths.rb +15 -0
- data/test/hpricot/test_preserved.rb +72 -0
- data/test/hpricot/test_xml.rb +26 -0
- data/test/html/sax/test_parser.rb +27 -0
- data/test/html/test_builder.rb +78 -0
- data/test/html/test_document.rb +22 -0
- data/test/test_convert_xpath.rb +173 -0
- data/test/test_nokogiri.rb +36 -0
- data/test/test_reader.rb +222 -0
- data/test/test_xslt_transforms.rb +29 -0
- data/test/xml/sax/test_parser.rb +93 -0
- data/test/xml/test_builder.rb +16 -0
- data/test/xml/test_document.rb +141 -0
- data/test/xml/test_node.rb +148 -0
- data/test/xml/test_node_set.rb +54 -0
- data/test/xml/test_text.rb +13 -0
- metadata +191 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
History.txt
|
2
|
+
Manifest.txt
|
3
|
+
README.txt
|
4
|
+
Rakefile
|
5
|
+
ext/nokogiri/extconf.rb
|
6
|
+
ext/nokogiri/html_document.c
|
7
|
+
ext/nokogiri/html_document.h
|
8
|
+
ext/nokogiri/html_sax_parser.c
|
9
|
+
ext/nokogiri/html_sax_parser.h
|
10
|
+
ext/nokogiri/native.c
|
11
|
+
ext/nokogiri/native.h
|
12
|
+
ext/nokogiri/xml_cdata.c
|
13
|
+
ext/nokogiri/xml_cdata.h
|
14
|
+
ext/nokogiri/xml_document.c
|
15
|
+
ext/nokogiri/xml_document.h
|
16
|
+
ext/nokogiri/xml_node.c
|
17
|
+
ext/nokogiri/xml_node.h
|
18
|
+
ext/nokogiri/xml_node_set.c
|
19
|
+
ext/nokogiri/xml_node_set.h
|
20
|
+
ext/nokogiri/xml_reader.c
|
21
|
+
ext/nokogiri/xml_reader.h
|
22
|
+
ext/nokogiri/xml_sax_parser.c
|
23
|
+
ext/nokogiri/xml_sax_parser.h
|
24
|
+
ext/nokogiri/xml_text.c
|
25
|
+
ext/nokogiri/xml_text.h
|
26
|
+
ext/nokogiri/xml_xpath.c
|
27
|
+
ext/nokogiri/xml_xpath.h
|
28
|
+
ext/nokogiri/xml_xpath_context.c
|
29
|
+
ext/nokogiri/xml_xpath_context.h
|
30
|
+
ext/nokogiri/xslt_stylesheet.c
|
31
|
+
ext/nokogiri/xslt_stylesheet.h
|
32
|
+
lib/nokogiri.rb
|
33
|
+
lib/nokogiri/css.rb
|
34
|
+
lib/nokogiri/css/generated_parser.rb
|
35
|
+
lib/nokogiri/css/generated_tokenizer.rb
|
36
|
+
lib/nokogiri/css/node.rb
|
37
|
+
lib/nokogiri/css/parser.rb
|
38
|
+
lib/nokogiri/css/parser.y
|
39
|
+
lib/nokogiri/css/tokenizer.rb
|
40
|
+
lib/nokogiri/css/tokenizer.rex
|
41
|
+
lib/nokogiri/css/xpath_visitor.rb
|
42
|
+
lib/nokogiri/decorators.rb
|
43
|
+
lib/nokogiri/decorators/hpricot.rb
|
44
|
+
lib/nokogiri/decorators/hpricot/node.rb
|
45
|
+
lib/nokogiri/decorators/hpricot/node_set.rb
|
46
|
+
lib/nokogiri/decorators/hpricot/xpath_visitor.rb
|
47
|
+
lib/nokogiri/hpricot.rb
|
48
|
+
lib/nokogiri/html.rb
|
49
|
+
lib/nokogiri/html/builder.rb
|
50
|
+
lib/nokogiri/html/document.rb
|
51
|
+
lib/nokogiri/html/sax/parser.rb
|
52
|
+
lib/nokogiri/version.rb
|
53
|
+
lib/nokogiri/xml.rb
|
54
|
+
lib/nokogiri/xml/after_handler.rb
|
55
|
+
lib/nokogiri/xml/before_handler.rb
|
56
|
+
lib/nokogiri/xml/builder.rb
|
57
|
+
lib/nokogiri/xml/document.rb
|
58
|
+
lib/nokogiri/xml/node.rb
|
59
|
+
lib/nokogiri/xml/node_set.rb
|
60
|
+
lib/nokogiri/xml/reader.rb
|
61
|
+
lib/nokogiri/xml/sax.rb
|
62
|
+
lib/nokogiri/xml/sax/document.rb
|
63
|
+
lib/nokogiri/xml/sax/parser.rb
|
64
|
+
lib/nokogiri/xml/text.rb
|
65
|
+
lib/nokogiri/xml/xpath.rb
|
66
|
+
lib/nokogiri/xslt.rb
|
67
|
+
lib/nokogiri/xslt/stylesheet.rb
|
68
|
+
nokogiri.gemspec
|
69
|
+
test/css/test_nthiness.rb
|
70
|
+
test/css/test_parser.rb
|
71
|
+
test/css/test_tokenizer.rb
|
72
|
+
test/files/staff.xml
|
73
|
+
test/files/staff.xslt
|
74
|
+
test/files/tlm.html
|
75
|
+
test/helper.rb
|
76
|
+
test/hpricot/files/basic.xhtml
|
77
|
+
test/hpricot/files/boingboing.html
|
78
|
+
test/hpricot/files/cy0.html
|
79
|
+
test/hpricot/files/immob.html
|
80
|
+
test/hpricot/files/pace_application.html
|
81
|
+
test/hpricot/files/tenderlove.html
|
82
|
+
test/hpricot/files/uswebgen.html
|
83
|
+
test/hpricot/files/utf8.html
|
84
|
+
test/hpricot/files/week9.html
|
85
|
+
test/hpricot/files/why.xml
|
86
|
+
test/hpricot/load_files.rb
|
87
|
+
test/hpricot/test_alter.rb
|
88
|
+
test/hpricot/test_builder.rb
|
89
|
+
test/hpricot/test_parser.rb
|
90
|
+
test/hpricot/test_paths.rb
|
91
|
+
test/hpricot/test_preserved.rb
|
92
|
+
test/hpricot/test_xml.rb
|
93
|
+
test/html/sax/test_parser.rb
|
94
|
+
test/html/test_builder.rb
|
95
|
+
test/html/test_document.rb
|
96
|
+
test/test_convert_xpath.rb
|
97
|
+
test/test_nokogiri.rb
|
98
|
+
test/test_reader.rb
|
99
|
+
test/test_xslt_transforms.rb
|
100
|
+
test/xml/sax/test_parser.rb
|
101
|
+
test/xml/test_builder.rb
|
102
|
+
test/xml/test_document.rb
|
103
|
+
test/xml/test_node.rb
|
104
|
+
test/xml/test_node_set.rb
|
105
|
+
test/xml/test_text.rb
|
data/README.txt
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
= Nokogiri
|
2
|
+
|
3
|
+
* http://github.com/tenderlove/nokogiri/tree/master
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
FIX (describe your package)
|
8
|
+
|
9
|
+
== FEATURES/PROBLEMS:
|
10
|
+
|
11
|
+
* FIX (list of features or problems)
|
12
|
+
|
13
|
+
== SYNOPSIS:
|
14
|
+
|
15
|
+
FIX (code sample of usage)
|
16
|
+
|
17
|
+
== REQUIREMENTS:
|
18
|
+
|
19
|
+
* FIX (list of requirements)
|
20
|
+
|
21
|
+
== INSTALL:
|
22
|
+
|
23
|
+
* FIX (sudo gem install, anything else)
|
24
|
+
|
25
|
+
== LICENSE:
|
26
|
+
|
27
|
+
(The MIT License)
|
28
|
+
|
29
|
+
Copyright (c) 2008:
|
30
|
+
|
31
|
+
* {Aaron Patterson}[http://tenderlovemaking.com]
|
32
|
+
* Mike Dalessio
|
33
|
+
|
34
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
35
|
+
a copy of this software and associated documentation files (the
|
36
|
+
'Software'), to deal in the Software without restriction, including
|
37
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
38
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
39
|
+
permit persons to whom the Software is furnished to do so, subject to
|
40
|
+
the following conditions:
|
41
|
+
|
42
|
+
The above copyright notice and this permission notice shall be
|
43
|
+
included in all copies or substantial portions of the Software.
|
44
|
+
|
45
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
46
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
47
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
48
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
49
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
50
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
51
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'hoe'
|
5
|
+
|
6
|
+
kind = Config::CONFIG['DLEXT']
|
7
|
+
|
8
|
+
LIB_DIR = File.expand_path(File.join(File.dirname(__FILE__), 'lib'))
|
9
|
+
$LOAD_PATH << LIB_DIR
|
10
|
+
|
11
|
+
GENERATED_PARSER = "lib/nokogiri/css/generated_parser.rb"
|
12
|
+
GENERATED_TOKENIZER = "lib/nokogiri/css/generated_tokenizer.rb"
|
13
|
+
|
14
|
+
EXT = "ext/nokogiri/native.#{kind}"
|
15
|
+
|
16
|
+
require 'nokogiri/version'
|
17
|
+
|
18
|
+
HOE = Hoe.new('nokogiri', Nokogiri::VERSION) do |p|
|
19
|
+
p.developer('Aaron Patterson', 'aaronp@rubyforge.org')
|
20
|
+
p.clean_globs = [
|
21
|
+
'ext/nokogiri/Makefile',
|
22
|
+
'ext/nokogiri/*.{o,so,bundle,a,log}',
|
23
|
+
'ext/nokogiri/conftest.dSYM',
|
24
|
+
GENERATED_PARSER,
|
25
|
+
GENERATED_TOKENIZER,
|
26
|
+
]
|
27
|
+
end
|
28
|
+
|
29
|
+
namespace :gem do
|
30
|
+
task :spec do
|
31
|
+
File.open("#{HOE.name}.gemspec", 'w') do |f|
|
32
|
+
HOE.spec.version = "#{HOE.version}.#{Time.now.strftime("%Y%m%d%H%M%S")}"
|
33
|
+
f.write(HOE.spec.to_ruby)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
desc "Run code-coverage analysis"
|
39
|
+
task :coverage do
|
40
|
+
rm_rf "coverage"
|
41
|
+
sh "rcov -x Library -I lib:test #{Dir[*HOE.test_globs].join(' ')}"
|
42
|
+
end
|
43
|
+
|
44
|
+
file GENERATED_PARSER => "lib/nokogiri/css/parser.y" do |t|
|
45
|
+
sh "racc -o #{t.name} #{t.prerequisites.first}"
|
46
|
+
end
|
47
|
+
|
48
|
+
file GENERATED_TOKENIZER => "lib/nokogiri/css/tokenizer.rex" do |t|
|
49
|
+
sh "frex -i --independent -o #{t.name} #{t.prerequisites.first}"
|
50
|
+
end
|
51
|
+
|
52
|
+
task 'ext/nokogiri/Makefile' do
|
53
|
+
Dir.chdir('ext/nokogiri') do
|
54
|
+
ruby 'extconf.rb'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
task EXT => 'ext/nokogiri/Makefile' do
|
59
|
+
Dir.chdir('ext/nokogiri') do
|
60
|
+
sh 'make'
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
task :build => [EXT, GENERATED_PARSER, GENERATED_TOKENIZER]
|
65
|
+
|
66
|
+
Rake::Task[:test].prerequisites << :build
|
67
|
+
Rake::Task[:check_manifest].prerequisites << GENERATED_PARSER
|
68
|
+
Rake::Task[:check_manifest].prerequisites << GENERATED_TOKENIZER
|
69
|
+
|
70
|
+
# vim: syntax=Ruby
|
@@ -0,0 +1,24 @@
|
|
1
|
+
ENV["ARCHFLAGS"] = "-arch #{`uname -p` =~ /powerpc/ ? 'ppc' : 'i386'}"
|
2
|
+
|
3
|
+
require 'mkmf'
|
4
|
+
|
5
|
+
$CFLAGS << " -g -DXP_UNIX"
|
6
|
+
$CFLAGS << " -O3 -Wall -Wextra -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline"
|
7
|
+
|
8
|
+
find_library('xml2', 'xmlParseDoc')
|
9
|
+
find_library('xslt', 'xsltParseStylesheetDoc')
|
10
|
+
|
11
|
+
unless find_header('libxml/xmlversion.h', '/usr/include/libxml2') &&
|
12
|
+
find_header('libxslt/xslt.h', '/usr/include')
|
13
|
+
abort "need libxml"
|
14
|
+
end
|
15
|
+
|
16
|
+
unless find_executable("racc")
|
17
|
+
abort "need racc, get the tarball from http://i.loveruby.net/archive/racc/racc-1.4.5-all.tar.gz"
|
18
|
+
end
|
19
|
+
|
20
|
+
unless find_executable("frex")
|
21
|
+
abort "need frex, sudo gem install aaronp-frex -s http://gems.github.com"
|
22
|
+
end
|
23
|
+
|
24
|
+
create_makefile('nokogiri/native')
|
@@ -0,0 +1,85 @@
|
|
1
|
+
#include <html_document.h>
|
2
|
+
|
3
|
+
static void dealloc(xmlDocPtr doc)
|
4
|
+
{
|
5
|
+
xmlFreeDoc(doc);
|
6
|
+
}
|
7
|
+
|
8
|
+
/*
|
9
|
+
* call-seq:
|
10
|
+
* serialize
|
11
|
+
*
|
12
|
+
* Serialize this document
|
13
|
+
*/
|
14
|
+
static VALUE serialize(VALUE self)
|
15
|
+
{
|
16
|
+
xmlDocPtr doc;
|
17
|
+
xmlChar *buf;
|
18
|
+
int size;
|
19
|
+
Data_Get_Struct(self, xmlDoc, doc);
|
20
|
+
|
21
|
+
htmlDocDumpMemory(doc, &buf, &size);
|
22
|
+
VALUE rb_str = rb_str_new((char *)buf, (long)size);
|
23
|
+
free(buf);
|
24
|
+
return rb_str;
|
25
|
+
}
|
26
|
+
|
27
|
+
/*
|
28
|
+
* call-seq:
|
29
|
+
* read_memory(string, url, encoding, options)
|
30
|
+
*
|
31
|
+
* Read the HTML document contained in +string+ with given +url+, +encoding+,
|
32
|
+
* and +options+. See Nokogiri::HTML.parse
|
33
|
+
*/
|
34
|
+
static VALUE read_memory( VALUE klass,
|
35
|
+
VALUE string,
|
36
|
+
VALUE url,
|
37
|
+
VALUE encoding,
|
38
|
+
VALUE options )
|
39
|
+
{
|
40
|
+
const char * c_buffer = StringValuePtr(string);
|
41
|
+
const char * c_url = (url == Qnil) ? NULL : StringValuePtr(url);
|
42
|
+
const char * c_enc = (encoding == Qnil) ? NULL : StringValuePtr(encoding);
|
43
|
+
int len = RSTRING(string)->len ;
|
44
|
+
|
45
|
+
htmlDocPtr doc = htmlReadMemory(c_buffer, len, c_url, c_enc, NUM2INT(options));
|
46
|
+
|
47
|
+
if(doc == NULL)
|
48
|
+
doc = htmlNewDoc((const xmlChar *)c_url, NULL);
|
49
|
+
|
50
|
+
return Nokogiri_wrap_xml_document(klass, doc);
|
51
|
+
}
|
52
|
+
|
53
|
+
/*
|
54
|
+
* call-seq:
|
55
|
+
* type
|
56
|
+
*
|
57
|
+
* The type for this document
|
58
|
+
*/
|
59
|
+
static VALUE type(VALUE self)
|
60
|
+
{
|
61
|
+
htmlDocPtr doc;
|
62
|
+
Data_Get_Struct(self, xmlDoc, doc);
|
63
|
+
return INT2NUM((int)doc->type);
|
64
|
+
}
|
65
|
+
|
66
|
+
VALUE cNokogiriHtmlDocument ;
|
67
|
+
void init_html_document()
|
68
|
+
{
|
69
|
+
/*
|
70
|
+
* HACK. This is so that rdoc will work with this C file.
|
71
|
+
*/
|
72
|
+
/*
|
73
|
+
VALUE nokogiri = rb_define_module("Nokogiri");
|
74
|
+
VALUE xml = rb_define_module_under(nokogiri, "HTML");
|
75
|
+
VALUE klass = rb_define_class_under(xml, "Document", rb_cObject);
|
76
|
+
*/
|
77
|
+
|
78
|
+
VALUE klass ;
|
79
|
+
klass = cNokogiriHtmlDocument = rb_const_get(mNokogiriHtml, rb_intern("Document"));
|
80
|
+
|
81
|
+
rb_define_singleton_method(klass, "read_memory", read_memory, 4);
|
82
|
+
|
83
|
+
rb_define_method(klass, "type", type, 0);
|
84
|
+
rb_define_method(klass, "serialize", serialize, 0);
|
85
|
+
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#include <html_sax_parser.h>
|
2
|
+
|
3
|
+
static VALUE native_parse_file(VALUE self, VALUE data, VALUE encoding)
|
4
|
+
{
|
5
|
+
xmlSAXHandlerPtr handler;
|
6
|
+
Data_Get_Struct(self, xmlSAXHandler, handler);
|
7
|
+
htmlSAXParseFile( StringValuePtr(data),
|
8
|
+
(const char *)StringValuePtr(encoding),
|
9
|
+
(htmlSAXHandlerPtr)handler,
|
10
|
+
(void *)self );
|
11
|
+
return data;
|
12
|
+
}
|
13
|
+
|
14
|
+
static VALUE native_parse_memory(VALUE self, VALUE data, VALUE encoding)
|
15
|
+
{
|
16
|
+
xmlSAXHandlerPtr handler;
|
17
|
+
Data_Get_Struct(self, xmlSAXHandler, handler);
|
18
|
+
htmlSAXParseDoc( (xmlChar *)StringValuePtr(data),
|
19
|
+
(const char *)StringValuePtr(encoding),
|
20
|
+
(htmlSAXHandlerPtr)handler,
|
21
|
+
(void *)self );
|
22
|
+
return data;
|
23
|
+
}
|
24
|
+
|
25
|
+
VALUE cNokogiriHtmlSaxParser ;
|
26
|
+
void init_html_sax_parser()
|
27
|
+
{
|
28
|
+
VALUE klass = cNokogiriHtmlSaxParser =
|
29
|
+
rb_const_get(mNokogiriHtmlSax, rb_intern("Parser"));
|
30
|
+
rb_define_private_method(klass, "native_parse_memory", native_parse_memory, 2);
|
31
|
+
rb_define_private_method(klass, "native_parse_file", native_parse_file, 2);
|
32
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#include <native.h>
|
2
|
+
|
3
|
+
VALUE mNokogiri ;
|
4
|
+
VALUE mNokogiriXml ;
|
5
|
+
VALUE mNokogiriHtml ;
|
6
|
+
VALUE mNokogiriXslt ;
|
7
|
+
VALUE mNokogiriXmlSax ;
|
8
|
+
VALUE mNokogiriHtmlSax ;
|
9
|
+
void Init_native()
|
10
|
+
{
|
11
|
+
mNokogiri = rb_const_get(rb_cObject, rb_intern("Nokogiri"));
|
12
|
+
mNokogiriXml = rb_const_get(mNokogiri, rb_intern("XML"));
|
13
|
+
mNokogiriHtml = rb_const_get(mNokogiri, rb_intern("HTML"));
|
14
|
+
mNokogiriXslt = rb_const_get(mNokogiri, rb_intern("XSLT"));
|
15
|
+
mNokogiriXmlSax = rb_const_get(mNokogiriXml, rb_intern("SAX"));
|
16
|
+
mNokogiriHtmlSax = rb_const_get(mNokogiriHtml, rb_intern("SAX"));
|
17
|
+
|
18
|
+
rb_const_set( mNokogiri,
|
19
|
+
rb_intern("LIBXML_VERSION"),
|
20
|
+
rb_str_new2(LIBXML_DOTTED_VERSION)
|
21
|
+
);
|
22
|
+
|
23
|
+
init_xml_document();
|
24
|
+
init_html_document();
|
25
|
+
init_xml_node();
|
26
|
+
init_xml_text();
|
27
|
+
init_xml_cdata();
|
28
|
+
init_xml_node_set();
|
29
|
+
init_xml_xpath_context();
|
30
|
+
init_xml_xpath();
|
31
|
+
init_xml_sax_parser();
|
32
|
+
init_xml_reader();
|
33
|
+
init_html_sax_parser();
|
34
|
+
init_xslt_stylesheet();
|
35
|
+
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#ifndef NOKOGIRI_NATIVE
|
2
|
+
#define NOKOGIRI_NATIVE
|
3
|
+
|
4
|
+
#include <stdlib.h>
|
5
|
+
#include <ruby.h>
|
6
|
+
#include <libxml/parser.h>
|
7
|
+
#include <libxml/xpath.h>
|
8
|
+
#include <libxml/xmlreader.h>
|
9
|
+
#include <libxml/HTMLparser.h>
|
10
|
+
#include <libxml/HTMLtree.h>
|
11
|
+
|
12
|
+
#include <xml_document.h>
|
13
|
+
#include <html_document.h>
|
14
|
+
#include <xml_node.h>
|
15
|
+
#include <xml_text.h>
|
16
|
+
#include <xml_cdata.h>
|
17
|
+
#include <xml_node_set.h>
|
18
|
+
#include <xml_xpath.h>
|
19
|
+
#include <xml_xpath_context.h>
|
20
|
+
#include <xml_sax_parser.h>
|
21
|
+
#include <xml_reader.h>
|
22
|
+
#include <html_sax_parser.h>
|
23
|
+
#include <xslt_stylesheet.h>
|
24
|
+
|
25
|
+
extern VALUE mNokogiri ;
|
26
|
+
extern VALUE mNokogiriXml ;
|
27
|
+
extern VALUE mNokogiriXmlSax ;
|
28
|
+
extern VALUE mNokogiriHtml ;
|
29
|
+
extern VALUE mNokogiriHtmlSax ;
|
30
|
+
extern VALUE mNokogiriXslt ;
|
31
|
+
|
32
|
+
#endif
|