nokogiri 1.3.3 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of nokogiri might be problematic. Click here for more details.
- data/CHANGELOG.ja.rdoc +48 -3
- data/CHANGELOG.rdoc +42 -0
- data/Manifest.txt +44 -29
- data/README.ja.rdoc +0 -2
- data/README.rdoc +4 -7
- data/Rakefile +42 -6
- data/bin/nokogiri +7 -5
- data/ext/nokogiri/extconf.rb +5 -21
- data/ext/nokogiri/html_document.c +14 -50
- data/ext/nokogiri/html_element_description.c +7 -7
- data/ext/nokogiri/html_entity_lookup.c +6 -4
- data/ext/nokogiri/html_sax_parser_context.c +92 -0
- data/ext/nokogiri/html_sax_parser_context.h +11 -0
- data/ext/nokogiri/nokogiri.c +9 -3
- data/ext/nokogiri/nokogiri.h +16 -20
- data/ext/nokogiri/xml_attr.c +1 -1
- data/ext/nokogiri/xml_attribute_decl.c +67 -0
- data/ext/nokogiri/xml_attribute_decl.h +9 -0
- data/ext/nokogiri/xml_cdata.c +6 -5
- data/ext/nokogiri/xml_comment.c +3 -2
- data/ext/nokogiri/xml_document.c +93 -23
- data/ext/nokogiri/xml_document_fragment.c +1 -3
- data/ext/nokogiri/xml_dtd.c +63 -6
- data/ext/nokogiri/xml_element_content.c +123 -0
- data/ext/nokogiri/xml_element_content.h +10 -0
- data/ext/nokogiri/xml_element_decl.c +69 -0
- data/ext/nokogiri/xml_element_decl.h +9 -0
- data/ext/nokogiri/xml_entity_decl.c +97 -0
- data/ext/nokogiri/xml_entity_decl.h +10 -0
- data/ext/nokogiri/xml_entity_reference.c +1 -1
- data/ext/nokogiri/xml_io.c +10 -3
- data/ext/nokogiri/xml_io.h +1 -0
- data/ext/nokogiri/xml_namespace.c +2 -2
- data/ext/nokogiri/xml_node.c +139 -34
- data/ext/nokogiri/xml_node.h +0 -1
- data/ext/nokogiri/xml_node_set.c +23 -16
- data/ext/nokogiri/xml_processing_instruction.c +1 -1
- data/ext/nokogiri/xml_reader.c +78 -50
- data/ext/nokogiri/xml_sax_parser.c +109 -168
- data/ext/nokogiri/xml_sax_parser.h +33 -0
- data/ext/nokogiri/xml_sax_parser_context.c +155 -0
- data/ext/nokogiri/xml_sax_parser_context.h +10 -0
- data/ext/nokogiri/xml_sax_push_parser.c +11 -6
- data/ext/nokogiri/xml_syntax_error.c +63 -12
- data/ext/nokogiri/xml_text.c +4 -3
- data/ext/nokogiri/xml_xpath.c +1 -1
- data/ext/nokogiri/xml_xpath_context.c +12 -25
- data/ext/nokogiri/xslt_stylesheet.c +3 -3
- data/lib/nokogiri.rb +4 -4
- data/lib/nokogiri/css/generated_tokenizer.rb +1 -0
- data/lib/nokogiri/css/node.rb +1 -9
- data/lib/nokogiri/css/xpath_visitor.rb +11 -21
- data/lib/nokogiri/ffi/html/document.rb +0 -9
- data/lib/nokogiri/ffi/html/sax/parser_context.rb +38 -0
- data/lib/nokogiri/ffi/io_callbacks.rb +4 -2
- data/lib/nokogiri/ffi/libxml.rb +44 -10
- data/lib/nokogiri/ffi/structs/common_node.rb +1 -1
- data/lib/nokogiri/ffi/structs/xml_attribute.rb +27 -0
- data/lib/nokogiri/ffi/structs/xml_dtd.rb +3 -1
- data/lib/nokogiri/ffi/structs/xml_element.rb +26 -0
- data/lib/nokogiri/ffi/structs/xml_element_content.rb +17 -0
- data/lib/nokogiri/ffi/structs/xml_entity.rb +32 -0
- data/lib/nokogiri/ffi/structs/xml_enumeration.rb +12 -0
- data/lib/nokogiri/ffi/structs/xml_parser_context.rb +19 -0
- data/lib/nokogiri/ffi/structs/xml_sax_push_parser_context.rb +4 -3
- data/lib/nokogiri/ffi/structs/xml_syntax_error.rb +1 -1
- data/lib/nokogiri/ffi/xml/attribute_decl.rb +27 -0
- data/lib/nokogiri/ffi/xml/comment.rb +2 -2
- data/lib/nokogiri/ffi/xml/document.rb +29 -12
- data/lib/nokogiri/ffi/xml/document_fragment.rb +0 -5
- data/lib/nokogiri/ffi/xml/dtd.rb +14 -3
- data/lib/nokogiri/ffi/xml/element_content.rb +43 -0
- data/lib/nokogiri/ffi/xml/element_decl.rb +19 -0
- data/lib/nokogiri/ffi/xml/entity_decl.rb +27 -0
- data/lib/nokogiri/ffi/xml/node.rb +45 -5
- data/lib/nokogiri/ffi/xml/node_set.rb +1 -1
- data/lib/nokogiri/ffi/xml/reader.rb +45 -24
- data/lib/nokogiri/ffi/xml/sax/parser.rb +27 -34
- data/lib/nokogiri/ffi/xml/sax/parser_context.rb +67 -0
- data/lib/nokogiri/ffi/xml/sax/push_parser.rb +5 -4
- data/lib/nokogiri/ffi/xml/syntax_error.rb +31 -16
- data/lib/nokogiri/ffi/xml/text.rb +2 -2
- data/lib/nokogiri/html.rb +1 -0
- data/lib/nokogiri/html/document.rb +39 -24
- data/lib/nokogiri/html/sax/parser.rb +2 -2
- data/lib/nokogiri/html/sax/parser_context.rb +16 -0
- data/lib/nokogiri/version.rb +1 -1
- data/lib/nokogiri/xml.rb +6 -1
- data/lib/nokogiri/xml/attr.rb +5 -0
- data/lib/nokogiri/xml/attribute_decl.rb +18 -0
- data/lib/nokogiri/xml/builder.rb +121 -13
- data/lib/nokogiri/xml/character_data.rb +7 -0
- data/lib/nokogiri/xml/document.rb +43 -29
- data/lib/nokogiri/xml/document_fragment.rb +26 -6
- data/lib/nokogiri/xml/dtd.rb +5 -5
- data/lib/nokogiri/xml/element_content.rb +36 -0
- data/lib/nokogiri/xml/element_decl.rb +13 -0
- data/lib/nokogiri/xml/entity_decl.rb +15 -0
- data/lib/nokogiri/xml/fragment_handler.rb +22 -11
- data/lib/nokogiri/xml/namespace.rb +6 -0
- data/lib/nokogiri/xml/node.rb +33 -15
- data/lib/nokogiri/xml/node_set.rb +66 -44
- data/lib/nokogiri/xml/pp.rb +2 -0
- data/lib/nokogiri/xml/pp/character_data.rb +18 -0
- data/lib/nokogiri/xml/pp/node.rb +56 -0
- data/lib/nokogiri/xml/reader.rb +8 -0
- data/lib/nokogiri/xml/sax.rb +1 -1
- data/lib/nokogiri/xml/sax/document.rb +18 -1
- data/lib/nokogiri/xml/sax/parser.rb +15 -8
- data/lib/nokogiri/xml/sax/parser_context.rb +16 -0
- data/lib/nokogiri/xml/sax/push_parser.rb +0 -3
- data/lib/nokogiri/xml/syntax_error.rb +4 -0
- data/lib/nokogiri/xslt/stylesheet.rb +1 -1
- data/test/css/test_nthiness.rb +1 -1
- data/test/css/test_parser.rb +1 -1
- data/test/css/test_tokenizer.rb +1 -1
- data/test/css/test_xpath_visitor.rb +1 -1
- data/test/ffi/test_document.rb +1 -1
- data/test/files/shift_jis.html +10 -0
- data/test/files/staff.dtd +10 -0
- data/test/helper.rb +12 -3
- data/test/html/sax/test_parser.rb +1 -1
- data/test/html/sax/test_parser_context.rb +48 -0
- data/test/html/test_builder.rb +8 -2
- data/test/html/test_document.rb +23 -1
- data/test/html/test_document_encoding.rb +15 -1
- data/test/html/test_document_fragment.rb +10 -1
- data/test/html/test_element_description.rb +1 -2
- data/test/html/test_named_characters.rb +1 -1
- data/test/html/test_node.rb +61 -1
- data/test/html/test_node_encoding.rb +27 -0
- data/test/test_convert_xpath.rb +1 -3
- data/test/test_css_cache.rb +1 -1
- data/test/test_gc.rb +1 -1
- data/test/test_memory_leak.rb +1 -1
- data/test/test_nokogiri.rb +3 -3
- data/test/test_reader.rb +29 -1
- data/test/test_xslt_transforms.rb +1 -1
- data/test/xml/node/test_save_options.rb +1 -1
- data/test/xml/node/test_subclass.rb +1 -1
- data/test/xml/sax/test_parser.rb +64 -3
- data/test/xml/sax/test_parser_context.rb +56 -0
- data/test/xml/sax/test_push_parser.rb +11 -1
- data/test/xml/test_attr.rb +1 -1
- data/test/xml/test_attribute_decl.rb +82 -0
- data/test/xml/test_builder.rb +95 -1
- data/test/xml/test_cdata.rb +1 -1
- data/test/xml/test_comment.rb +7 -1
- data/test/xml/test_document.rb +147 -6
- data/test/xml/test_document_encoding.rb +1 -1
- data/test/xml/test_document_fragment.rb +55 -5
- data/test/xml/test_dtd.rb +40 -5
- data/test/xml/test_dtd_encoding.rb +3 -1
- data/test/xml/test_element_content.rb +56 -0
- data/test/xml/test_element_decl.rb +73 -0
- data/test/xml/test_entity_decl.rb +83 -0
- data/test/xml/test_entity_reference.rb +1 -1
- data/test/xml/test_namespace.rb +21 -1
- data/test/xml/test_node.rb +70 -4
- data/test/xml/test_node_attributes.rb +1 -1
- data/test/xml/test_node_encoding.rb +1 -1
- data/test/xml/test_node_set.rb +136 -2
- data/test/xml/test_parse_options.rb +1 -1
- data/test/xml/test_processing_instruction.rb +1 -1
- data/test/xml/test_reader_encoding.rb +1 -1
- data/test/xml/test_relax_ng.rb +1 -1
- data/test/xml/test_schema.rb +1 -1
- data/test/xml/test_syntax_error.rb +27 -0
- data/test/xml/test_text.rb +13 -1
- data/test/xml/test_unparented_node.rb +1 -1
- data/test/xml/test_xpath.rb +1 -1
- metadata +57 -40
- data/ext/nokogiri/html_sax_parser.c +0 -57
- data/ext/nokogiri/html_sax_parser.h +0 -11
- data/lib/action-nokogiri.rb +0 -38
- data/lib/nokogiri/decorators.rb +0 -2
- data/lib/nokogiri/decorators/hpricot.rb +0 -3
- data/lib/nokogiri/decorators/hpricot/node.rb +0 -56
- data/lib/nokogiri/decorators/hpricot/node_set.rb +0 -54
- data/lib/nokogiri/decorators/hpricot/xpath_visitor.rb +0 -30
- data/lib/nokogiri/ffi/html/sax/parser.rb +0 -21
- data/lib/nokogiri/hpricot.rb +0 -92
- data/lib/nokogiri/xml/entity_declaration.rb +0 -11
- data/lib/nokogiri/xml/sax/legacy_handlers.rb +0 -65
- data/test/hpricot/files/basic.xhtml +0 -17
- data/test/hpricot/files/boingboing.html +0 -2266
- data/test/hpricot/files/cy0.html +0 -3653
- data/test/hpricot/files/immob.html +0 -400
- data/test/hpricot/files/pace_application.html +0 -1320
- data/test/hpricot/files/tenderlove.html +0 -16
- data/test/hpricot/files/uswebgen.html +0 -220
- data/test/hpricot/files/utf8.html +0 -1054
- data/test/hpricot/files/week9.html +0 -1723
- data/test/hpricot/files/why.xml +0 -19
- data/test/hpricot/load_files.rb +0 -11
- data/test/hpricot/test_alter.rb +0 -68
- data/test/hpricot/test_builder.rb +0 -20
- data/test/hpricot/test_parser.rb +0 -350
- data/test/hpricot/test_paths.rb +0 -15
- data/test/hpricot/test_preserved.rb +0 -77
- data/test/hpricot/test_xml.rb +0 -30
@@ -1,57 +0,0 @@
|
|
1
|
-
#include <html_sax_parser.h>
|
2
|
-
|
3
|
-
/*
|
4
|
-
* call-seq:
|
5
|
-
* native_parse_file(data, encoding)
|
6
|
-
*
|
7
|
-
* Parse +data+ with +encoding+
|
8
|
-
*/
|
9
|
-
static VALUE native_parse_file(VALUE self, VALUE data, VALUE encoding)
|
10
|
-
{
|
11
|
-
xmlSAXHandlerPtr handler;
|
12
|
-
htmlDocPtr hdoc ;
|
13
|
-
Data_Get_Struct(self, xmlSAXHandler, handler);
|
14
|
-
hdoc = htmlSAXParseFile( StringValuePtr(data),
|
15
|
-
(const char *)StringValuePtr(encoding),
|
16
|
-
(htmlSAXHandlerPtr)handler,
|
17
|
-
(void *)self );
|
18
|
-
xmlFreeDoc(hdoc);
|
19
|
-
return data;
|
20
|
-
}
|
21
|
-
|
22
|
-
/*
|
23
|
-
* call-seq:
|
24
|
-
* native_parse_memory(data, encoding)
|
25
|
-
*
|
26
|
-
* Parse +data+ with +encoding+
|
27
|
-
*/
|
28
|
-
static VALUE native_parse_memory(VALUE self, VALUE data, VALUE encoding)
|
29
|
-
{
|
30
|
-
xmlSAXHandlerPtr handler;
|
31
|
-
htmlDocPtr hdoc ;
|
32
|
-
Data_Get_Struct(self, xmlSAXHandler, handler);
|
33
|
-
hdoc = htmlSAXParseDoc( (xmlChar *)StringValuePtr(data),
|
34
|
-
(const char *)StringValuePtr(encoding),
|
35
|
-
(htmlSAXHandlerPtr)handler,
|
36
|
-
(void *)self );
|
37
|
-
xmlFreeDoc(hdoc);
|
38
|
-
return data;
|
39
|
-
}
|
40
|
-
|
41
|
-
VALUE cNokogiriHtmlSaxParser ;
|
42
|
-
void init_html_sax_parser()
|
43
|
-
{
|
44
|
-
VALUE nokogiri = rb_define_module("Nokogiri");
|
45
|
-
VALUE html = rb_define_module_under(nokogiri, "HTML");
|
46
|
-
VALUE sax = rb_define_module_under(html, "SAX");
|
47
|
-
/*
|
48
|
-
* Nokogiri::HTML::SAX::Parser is used for parsing HTML with SAX
|
49
|
-
* callbacks.
|
50
|
-
*/
|
51
|
-
VALUE klass = rb_define_class_under(sax, "Parser", cNokogiriXmlSaxParser);
|
52
|
-
|
53
|
-
cNokogiriHtmlSaxParser = klass;
|
54
|
-
|
55
|
-
rb_define_private_method(klass, "native_parse_memory", native_parse_memory, 2);
|
56
|
-
rb_define_private_method(klass, "native_parse_file", native_parse_file, 2);
|
57
|
-
}
|
data/lib/action-nokogiri.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'nokogiri'
|
2
|
-
|
3
|
-
#
|
4
|
-
# to use this in your Rails view or controller tests, simply:
|
5
|
-
#
|
6
|
-
# require 'action-nokogiri'
|
7
|
-
#
|
8
|
-
# class KittehControllerTest < ActionController::TestCase
|
9
|
-
# def test_i_can_does_test_with_nokogiri
|
10
|
-
# get(:index, {:wants => "cheezburgers"})
|
11
|
-
# assert @response.html.at("h2.lolcats")
|
12
|
-
# end
|
13
|
-
#
|
14
|
-
module ActionController
|
15
|
-
module TestResponseBehavior # :nodoc:
|
16
|
-
|
17
|
-
###
|
18
|
-
# Get your response as a Nokogiri::XML::Document using the
|
19
|
-
# Nokogiri.HTML parser
|
20
|
-
def html(flavor=nil)
|
21
|
-
warn "@response.html is deprecated and will be removed in nokogiri 1.4.0"
|
22
|
-
if flavor == :hpricot
|
23
|
-
@_nokogiri_html_hpricot ||= Nokogiri::Hpricot(body)
|
24
|
-
else
|
25
|
-
@_nokogiri_html_vanilla ||= Nokogiri::HTML(body)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
###
|
30
|
-
# Get your response as a Nokogiri::XML::Document using the
|
31
|
-
# Nokogiri.XML parser
|
32
|
-
def xml
|
33
|
-
warn "@response.html is deprecated and will be removed in nokogiri 1.4.0"
|
34
|
-
@_nokogiri_xml ||= Nokogiri::XML(body)
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
end
|
data/lib/nokogiri/decorators.rb
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
module Nokogiri
|
2
|
-
module Decorators
|
3
|
-
module Hpricot
|
4
|
-
module Node # :nodoc:
|
5
|
-
def search *paths
|
6
|
-
ns = paths.last.is_a?(Hash) ? paths.pop : {}
|
7
|
-
converted = paths.map { |path|
|
8
|
-
convert_to_xpath(path)
|
9
|
-
}.flatten.uniq
|
10
|
-
|
11
|
-
super(*converted + [ns])
|
12
|
-
end
|
13
|
-
def /(path); search(path) end
|
14
|
-
|
15
|
-
def xpath *args
|
16
|
-
return super if args.length > 0
|
17
|
-
path
|
18
|
-
end
|
19
|
-
|
20
|
-
def raw_attributes; self end
|
21
|
-
|
22
|
-
def get_element_by_id element_id
|
23
|
-
search("//*[@id='#{element_id}']").first
|
24
|
-
end
|
25
|
-
|
26
|
-
def get_elements_by_tag_name tag
|
27
|
-
search("//#{tag}")
|
28
|
-
end
|
29
|
-
|
30
|
-
def convert_to_xpath(rule)
|
31
|
-
rule = rule.to_s
|
32
|
-
case rule
|
33
|
-
when %r{^//}
|
34
|
-
[".#{Hpricot::XPathVisitor.xpath_namespace_helper(rule)}"]
|
35
|
-
when %r{^/}
|
36
|
-
[Hpricot::XPathVisitor.xpath_namespace_helper(rule)]
|
37
|
-
when %r{^.//}
|
38
|
-
[Hpricot::XPathVisitor.xpath_namespace_helper(rule)]
|
39
|
-
else
|
40
|
-
visitor = CSS::XPathVisitor.new
|
41
|
-
visitor.extend(Hpricot::XPathVisitor)
|
42
|
-
CSS.xpath_for(rule, :prefix => ".//", :visitor => visitor)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def target
|
47
|
-
name
|
48
|
-
end
|
49
|
-
|
50
|
-
def to_original_html
|
51
|
-
to_html
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
module Nokogiri
|
2
|
-
module Decorators
|
3
|
-
module Hpricot
|
4
|
-
module NodeSet
|
5
|
-
|
6
|
-
# Select nodes matching the supplied rule.
|
7
|
-
# Note that positional rules (like <tt>:nth()</tt>) aren't currently supported.
|
8
|
-
#
|
9
|
-
# example:
|
10
|
-
# node_set.filter('.ohmy') # selects nodes from the set with class "ohmy"
|
11
|
-
# node_set.filter('a#link2') # selects nodes from the set with child node <a id='link2'>
|
12
|
-
# node_set.filter('a[@id="link2"]') # selects nodes from the set with child node <a id='link2'>
|
13
|
-
def filter(rule)
|
14
|
-
filter_transformer( lambda {|j| j}, rule ) # identity transformer
|
15
|
-
end
|
16
|
-
|
17
|
-
# The complement to filter, select nodes <em>not</em> matching the supplied rule.
|
18
|
-
# Note that positional rules (like <tt>:nth()</tt>) aren't currently supported.
|
19
|
-
#
|
20
|
-
# See filter for examples.
|
21
|
-
#
|
22
|
-
# Also note that you can pass a XML::Node object instead of a
|
23
|
-
# rule to remove that object from the node set (if it is
|
24
|
-
# present):
|
25
|
-
# node_set.not(node_to_exclude) # selects all nodes EXCEPT node_to_exclude
|
26
|
-
#
|
27
|
-
def not(rule)
|
28
|
-
filter_transformer( lambda {|j| !j}, rule ) # negation transformer
|
29
|
-
end
|
30
|
-
|
31
|
-
private
|
32
|
-
def filter_transformer(transformer, rule) # :nodoc:
|
33
|
-
sub_set = XML::NodeSet.new(document)
|
34
|
-
document.decorate(sub_set)
|
35
|
-
|
36
|
-
if rule.is_a?(XML::Node)
|
37
|
-
each { |node| sub_set << node if transformer.call(node == rule) }
|
38
|
-
return sub_set
|
39
|
-
end
|
40
|
-
|
41
|
-
ctx = CSS.parse(rule.to_s)
|
42
|
-
visitor = CSS::XPathVisitor.new
|
43
|
-
visitor.extend(Hpricot::XPathVisitor)
|
44
|
-
each do |node|
|
45
|
-
if transformer.call(node.at(".//self::" + visitor.accept(ctx.first)))
|
46
|
-
sub_set << node
|
47
|
-
end
|
48
|
-
end
|
49
|
-
sub_set
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
module Nokogiri
|
2
|
-
module Decorators
|
3
|
-
module Hpricot
|
4
|
-
####
|
5
|
-
# This mixin does custom adjustments to deal with _whyML
|
6
|
-
module XPathVisitor
|
7
|
-
###
|
8
|
-
# Visit attribute condition nodes with +node+
|
9
|
-
def visit_attribute_condition node
|
10
|
-
unless (node.value.first.type == :FUNCTION) or (node.value.first.value.first =~ /^@/)
|
11
|
-
node.value.first.value[0] = "child::" +
|
12
|
-
node.value.first.value[0]
|
13
|
-
end
|
14
|
-
super(node).gsub(/child::text\(\)/, 'normalize-space(child::text())')
|
15
|
-
end
|
16
|
-
|
17
|
-
# take a path like '//t:sam' and convert to xpath "*[name()='t:sam']"
|
18
|
-
def self.xpath_namespace_helper rule
|
19
|
-
rule.split(/\//).collect do |tag|
|
20
|
-
if match = tag.match(/^(\w+:\w+)(.*)/)
|
21
|
-
"*[name()='#{match[1]}']#{match[2]}"
|
22
|
-
else
|
23
|
-
tag
|
24
|
-
end
|
25
|
-
end.join("/")
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module Nokogiri
|
2
|
-
module HTML
|
3
|
-
module SAX
|
4
|
-
class Parser < XML::SAX::Parser
|
5
|
-
|
6
|
-
def native_parse_file(data, encoding) # :nodoc:
|
7
|
-
docptr = LibXML.htmlSAXParseFile(data, encoding, cstruct, nil)
|
8
|
-
LibXML.xmlFreeDoc docptr
|
9
|
-
data
|
10
|
-
end
|
11
|
-
|
12
|
-
def native_parse_memory(data, encoding) # :nodoc:
|
13
|
-
docptr = LibXML.htmlSAXParseDoc(data, encoding, cstruct, nil)
|
14
|
-
LibXML.xmlFreeDoc docptr
|
15
|
-
data
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
data/lib/nokogiri/hpricot.rb
DELETED
@@ -1,92 +0,0 @@
|
|
1
|
-
require 'nokogiri'
|
2
|
-
|
3
|
-
module Nokogiri
|
4
|
-
module Hpricot
|
5
|
-
# STag compatibility proxy
|
6
|
-
STag = String
|
7
|
-
# Elem compatibility proxy
|
8
|
-
Elem = XML::Node
|
9
|
-
# NamedCharacters compatibility proxy
|
10
|
-
NamedCharacters = Nokogiri::HTML::NamedCharacters
|
11
|
-
class << self
|
12
|
-
# parse proxy
|
13
|
-
def parse(*args)
|
14
|
-
warn <<-eomsg
|
15
|
-
Nokogiri::Hpricot.parse is deprecated and will be extracted to it's own gem
|
16
|
-
when Nokogiri 1.4.0 is released. Please switch to Nokogiri(), or be prepared
|
17
|
-
to install the compatibility layer.
|
18
|
-
#{caller.first}
|
19
|
-
eomsg
|
20
|
-
doc = Nokogiri.parse(*args)
|
21
|
-
add_decorators(doc)
|
22
|
-
end
|
23
|
-
|
24
|
-
# XML proxy
|
25
|
-
def XML(string)
|
26
|
-
warn <<-eomsg
|
27
|
-
Nokogiri::Hpricot.parse is deprecated and will be extracted to it's own gem
|
28
|
-
when Nokogiri 1.4.0 is released. Please switch to Nokogiri::XML(), or be
|
29
|
-
prepared to install the compatibility layer.
|
30
|
-
#{caller.first}
|
31
|
-
eomsg
|
32
|
-
doc = Nokogiri::XML::Document.parse(string)
|
33
|
-
add_decorators(doc)
|
34
|
-
end
|
35
|
-
|
36
|
-
# HTML proxy
|
37
|
-
def HTML(string)
|
38
|
-
warn <<-eomsg
|
39
|
-
Nokogiri::Hpricot.parse is deprecated and will be extracted to it's own gem
|
40
|
-
when Nokogiri 1.4.0 is released. Please switch to Nokogiri::HTML(), or be
|
41
|
-
prepared to install the compatibility layer.
|
42
|
-
#{caller.first}
|
43
|
-
eomsg
|
44
|
-
doc = Nokogiri::HTML::Document.parse(string)
|
45
|
-
add_decorators(doc)
|
46
|
-
end
|
47
|
-
|
48
|
-
# make proxy
|
49
|
-
def make string
|
50
|
-
warn <<-eomsg
|
51
|
-
Nokogiri::Hpricot.parse is deprecated and will be extracted to it's own gem
|
52
|
-
when Nokogiri 1.4.0 is released. Please switch to Nokogiri::HTML.make(), or be
|
53
|
-
prepared to install the compatibility layer.
|
54
|
-
#{caller.first}
|
55
|
-
eomsg
|
56
|
-
doc = XML::Document.new
|
57
|
-
ns = XML::NodeSet.new(doc)
|
58
|
-
ns << XML::Text.new(string, doc)
|
59
|
-
ns
|
60
|
-
end
|
61
|
-
|
62
|
-
# Add compatibility decorators
|
63
|
-
def add_decorators(doc)
|
64
|
-
doc.decorators(XML::Node) << Decorators::Hpricot::Node
|
65
|
-
doc.decorators(XML::NodeSet) << Decorators::Hpricot::NodeSet
|
66
|
-
doc.decorate!
|
67
|
-
doc
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
class << self
|
73
|
-
###
|
74
|
-
# Parse a document and apply the Hpricot decorators for Hpricot
|
75
|
-
# compatibility mode.
|
76
|
-
def Hpricot(*args, &block)
|
77
|
-
warn <<-eomsg
|
78
|
-
Nokogiri::Hpricot.parse is deprecated and will be extracted to it's own gem
|
79
|
-
when Nokogiri 1.4.0 is released. Please switch to Nokogiri(), or be
|
80
|
-
prepared to install the compatibility layer.
|
81
|
-
#{caller.first}
|
82
|
-
eomsg
|
83
|
-
if block_given?
|
84
|
-
builder = Nokogiri::HTML::Builder.new(&block)
|
85
|
-
Nokogiri::Hpricot.add_decorators(builder.doc)
|
86
|
-
else
|
87
|
-
doc = Nokogiri.parse(*args)
|
88
|
-
Nokogiri::Hpricot.add_decorators(doc)
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
@@ -1,65 +0,0 @@
|
|
1
|
-
module Nokogiri
|
2
|
-
module XML
|
3
|
-
module SAX
|
4
|
-
# :stopdoc:
|
5
|
-
module LegacyHandlers
|
6
|
-
def start_element_namespace name,
|
7
|
-
attrs = [],
|
8
|
-
prefix = nil,
|
9
|
-
uri = nil,
|
10
|
-
ns = []
|
11
|
-
|
12
|
-
##
|
13
|
-
# Deal with legacy interface
|
14
|
-
if @document.respond_to? :start_element_ns
|
15
|
-
unless @warned
|
16
|
-
warn <<-eowarn
|
17
|
-
Nokogiri::XML::SAX::Document#start_element_ns and end_element_ns are deprecated,
|
18
|
-
please change to start_element_namespace. start_element_ns will be removed by
|
19
|
-
version 1.4.0 or by August 1st, whichever comes first.
|
20
|
-
eowarn
|
21
|
-
@warned = true
|
22
|
-
end
|
23
|
-
attr_hash = {}
|
24
|
-
attrs.each do |attr|
|
25
|
-
attr_hash[attr.localname] = attr.value
|
26
|
-
end
|
27
|
-
ns_hash = Hash[*ns.flatten]
|
28
|
-
@document.start_element_ns name, attr_hash, prefix, uri, ns_hash
|
29
|
-
end
|
30
|
-
|
31
|
-
###
|
32
|
-
# Deal with SAX v1 interface
|
33
|
-
name = [prefix, name].compact.join(':')
|
34
|
-
attributes = ns.map { |ns_prefix,ns_uri|
|
35
|
-
[['xmlns', ns_prefix].compact.join(':'), ns_uri]
|
36
|
-
} + attrs.map { |attr|
|
37
|
-
[[attr.prefix, attr.localname].compact.join(':'), attr.value]
|
38
|
-
}.flatten
|
39
|
-
@document.start_element name, attributes
|
40
|
-
end
|
41
|
-
|
42
|
-
def end_element_namespace name, prefix = nil, uri = nil
|
43
|
-
##
|
44
|
-
# Deal with legacy interface
|
45
|
-
if @document.respond_to? :end_element_ns
|
46
|
-
unless @warned
|
47
|
-
warn <<-eowarn
|
48
|
-
Nokogiri::XML::SAX::Document#start_element_ns and end_element_ns are deprecated,
|
49
|
-
please change to start_element_namespace. start_element_ns will be removed by
|
50
|
-
version 1.4.0 or by August 1st, whichever comes first.
|
51
|
-
eowarn
|
52
|
-
@warned = true
|
53
|
-
end
|
54
|
-
@document.end_element_ns name, prefix, uri
|
55
|
-
end
|
56
|
-
|
57
|
-
###
|
58
|
-
# Deal with SAX v1 interface
|
59
|
-
@document.end_element [prefix, name].compact.join(':')
|
60
|
-
end
|
61
|
-
end
|
62
|
-
# :startdoc:
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|