nokogiri 1.14.0-arm-linux
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.
- checksums.yaml +7 -0
- data/Gemfile +38 -0
- data/LICENSE-DEPENDENCIES.md +2224 -0
- data/LICENSE.md +9 -0
- data/README.md +287 -0
- data/bin/nokogiri +131 -0
- data/dependencies.yml +41 -0
- data/ext/nokogiri/depend +38 -0
- data/ext/nokogiri/extconf.rb +1082 -0
- data/ext/nokogiri/gumbo.c +594 -0
- data/ext/nokogiri/html4_document.c +166 -0
- data/ext/nokogiri/html4_element_description.c +294 -0
- data/ext/nokogiri/html4_entity_lookup.c +37 -0
- data/ext/nokogiri/html4_sax_parser_context.c +114 -0
- data/ext/nokogiri/html4_sax_push_parser.c +95 -0
- data/ext/nokogiri/include/libexslt/exslt.h +108 -0
- data/ext/nokogiri/include/libexslt/exsltconfig.h +70 -0
- data/ext/nokogiri/include/libexslt/exsltexports.h +63 -0
- data/ext/nokogiri/include/libxml2/libxml/HTMLparser.h +306 -0
- data/ext/nokogiri/include/libxml2/libxml/HTMLtree.h +147 -0
- data/ext/nokogiri/include/libxml2/libxml/SAX.h +204 -0
- data/ext/nokogiri/include/libxml2/libxml/SAX2.h +172 -0
- data/ext/nokogiri/include/libxml2/libxml/c14n.h +128 -0
- data/ext/nokogiri/include/libxml2/libxml/catalog.h +182 -0
- data/ext/nokogiri/include/libxml2/libxml/chvalid.h +230 -0
- data/ext/nokogiri/include/libxml2/libxml/debugXML.h +217 -0
- data/ext/nokogiri/include/libxml2/libxml/dict.h +81 -0
- data/ext/nokogiri/include/libxml2/libxml/encoding.h +232 -0
- data/ext/nokogiri/include/libxml2/libxml/entities.h +153 -0
- data/ext/nokogiri/include/libxml2/libxml/globals.h +499 -0
- data/ext/nokogiri/include/libxml2/libxml/hash.h +236 -0
- data/ext/nokogiri/include/libxml2/libxml/list.h +137 -0
- data/ext/nokogiri/include/libxml2/libxml/nanoftp.h +186 -0
- data/ext/nokogiri/include/libxml2/libxml/nanohttp.h +81 -0
- data/ext/nokogiri/include/libxml2/libxml/parser.h +1244 -0
- data/ext/nokogiri/include/libxml2/libxml/parserInternals.h +656 -0
- data/ext/nokogiri/include/libxml2/libxml/pattern.h +100 -0
- data/ext/nokogiri/include/libxml2/libxml/relaxng.h +218 -0
- data/ext/nokogiri/include/libxml2/libxml/schemasInternals.h +958 -0
- data/ext/nokogiri/include/libxml2/libxml/schematron.h +142 -0
- data/ext/nokogiri/include/libxml2/libxml/threads.h +91 -0
- data/ext/nokogiri/include/libxml2/libxml/tree.h +1312 -0
- data/ext/nokogiri/include/libxml2/libxml/uri.h +94 -0
- data/ext/nokogiri/include/libxml2/libxml/valid.h +463 -0
- data/ext/nokogiri/include/libxml2/libxml/xinclude.h +129 -0
- data/ext/nokogiri/include/libxml2/libxml/xlink.h +189 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlIO.h +368 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlautomata.h +146 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlerror.h +947 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlexports.h +77 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlmemory.h +226 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlmodule.h +57 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlreader.h +428 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlregexp.h +222 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlsave.h +88 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlschemas.h +246 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlschemastypes.h +152 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlstring.h +140 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlunicode.h +202 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlversion.h +503 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlwriter.h +488 -0
- data/ext/nokogiri/include/libxml2/libxml/xpath.h +575 -0
- data/ext/nokogiri/include/libxml2/libxml/xpathInternals.h +632 -0
- data/ext/nokogiri/include/libxml2/libxml/xpointer.h +137 -0
- data/ext/nokogiri/include/libxslt/attributes.h +38 -0
- data/ext/nokogiri/include/libxslt/documents.h +93 -0
- data/ext/nokogiri/include/libxslt/extensions.h +262 -0
- data/ext/nokogiri/include/libxslt/extra.h +72 -0
- data/ext/nokogiri/include/libxslt/functions.h +78 -0
- data/ext/nokogiri/include/libxslt/imports.h +75 -0
- data/ext/nokogiri/include/libxslt/keys.h +53 -0
- data/ext/nokogiri/include/libxslt/namespaces.h +68 -0
- data/ext/nokogiri/include/libxslt/numbersInternals.h +73 -0
- data/ext/nokogiri/include/libxslt/pattern.h +84 -0
- data/ext/nokogiri/include/libxslt/preproc.h +43 -0
- data/ext/nokogiri/include/libxslt/security.h +104 -0
- data/ext/nokogiri/include/libxslt/templates.h +77 -0
- data/ext/nokogiri/include/libxslt/transform.h +207 -0
- data/ext/nokogiri/include/libxslt/variables.h +118 -0
- data/ext/nokogiri/include/libxslt/xslt.h +110 -0
- data/ext/nokogiri/include/libxslt/xsltInternals.h +1982 -0
- data/ext/nokogiri/include/libxslt/xsltconfig.h +179 -0
- data/ext/nokogiri/include/libxslt/xsltexports.h +64 -0
- data/ext/nokogiri/include/libxslt/xsltlocale.h +76 -0
- data/ext/nokogiri/include/libxslt/xsltutils.h +310 -0
- data/ext/nokogiri/libxml2_backwards_compat.c +121 -0
- data/ext/nokogiri/nokogiri.c +260 -0
- data/ext/nokogiri/nokogiri.h +235 -0
- data/ext/nokogiri/test_global_handlers.c +40 -0
- data/ext/nokogiri/xml_attr.c +103 -0
- data/ext/nokogiri/xml_attribute_decl.c +70 -0
- data/ext/nokogiri/xml_cdata.c +57 -0
- data/ext/nokogiri/xml_comment.c +62 -0
- data/ext/nokogiri/xml_document.c +689 -0
- data/ext/nokogiri/xml_document_fragment.c +44 -0
- data/ext/nokogiri/xml_dtd.c +208 -0
- data/ext/nokogiri/xml_element_content.c +128 -0
- data/ext/nokogiri/xml_element_decl.c +69 -0
- data/ext/nokogiri/xml_encoding_handler.c +104 -0
- data/ext/nokogiri/xml_entity_decl.c +112 -0
- data/ext/nokogiri/xml_entity_reference.c +50 -0
- data/ext/nokogiri/xml_namespace.c +186 -0
- data/ext/nokogiri/xml_node.c +2425 -0
- data/ext/nokogiri/xml_node_set.c +496 -0
- data/ext/nokogiri/xml_processing_instruction.c +54 -0
- data/ext/nokogiri/xml_reader.c +794 -0
- data/ext/nokogiri/xml_relax_ng.c +183 -0
- data/ext/nokogiri/xml_sax_parser.c +316 -0
- data/ext/nokogiri/xml_sax_parser_context.c +283 -0
- data/ext/nokogiri/xml_sax_push_parser.c +166 -0
- data/ext/nokogiri/xml_schema.c +282 -0
- data/ext/nokogiri/xml_syntax_error.c +85 -0
- data/ext/nokogiri/xml_text.c +48 -0
- data/ext/nokogiri/xml_xpath_context.c +413 -0
- data/ext/nokogiri/xslt_stylesheet.c +363 -0
- data/gumbo-parser/CHANGES.md +63 -0
- data/gumbo-parser/Makefile +111 -0
- data/gumbo-parser/THANKS +27 -0
- data/lib/nokogiri/2.7/nokogiri.so +0 -0
- data/lib/nokogiri/3.0/nokogiri.so +0 -0
- data/lib/nokogiri/3.1/nokogiri.so +0 -0
- data/lib/nokogiri/3.2/nokogiri.so +0 -0
- data/lib/nokogiri/class_resolver.rb +67 -0
- data/lib/nokogiri/css/node.rb +54 -0
- data/lib/nokogiri/css/parser.rb +770 -0
- data/lib/nokogiri/css/parser.y +277 -0
- data/lib/nokogiri/css/parser_extras.rb +96 -0
- data/lib/nokogiri/css/syntax_error.rb +9 -0
- data/lib/nokogiri/css/tokenizer.rb +155 -0
- data/lib/nokogiri/css/tokenizer.rex +56 -0
- data/lib/nokogiri/css/xpath_visitor.rb +359 -0
- data/lib/nokogiri/css.rb +66 -0
- data/lib/nokogiri/decorators/slop.rb +44 -0
- data/lib/nokogiri/encoding_handler.rb +57 -0
- data/lib/nokogiri/extension.rb +32 -0
- data/lib/nokogiri/gumbo.rb +15 -0
- data/lib/nokogiri/html.rb +48 -0
- data/lib/nokogiri/html4/builder.rb +37 -0
- data/lib/nokogiri/html4/document.rb +214 -0
- data/lib/nokogiri/html4/document_fragment.rb +54 -0
- data/lib/nokogiri/html4/element_description.rb +25 -0
- data/lib/nokogiri/html4/element_description_defaults.rb +572 -0
- data/lib/nokogiri/html4/encoding_reader.rb +121 -0
- data/lib/nokogiri/html4/entity_lookup.rb +15 -0
- data/lib/nokogiri/html4/sax/parser.rb +63 -0
- data/lib/nokogiri/html4/sax/parser_context.rb +20 -0
- data/lib/nokogiri/html4/sax/push_parser.rb +37 -0
- data/lib/nokogiri/html4.rb +47 -0
- data/lib/nokogiri/html5/document.rb +168 -0
- data/lib/nokogiri/html5/document_fragment.rb +90 -0
- data/lib/nokogiri/html5/node.rb +98 -0
- data/lib/nokogiri/html5.rb +389 -0
- data/lib/nokogiri/jruby/dependencies.rb +3 -0
- data/lib/nokogiri/jruby/nokogiri_jars.rb +43 -0
- data/lib/nokogiri/syntax_error.rb +6 -0
- data/lib/nokogiri/version/constant.rb +6 -0
- data/lib/nokogiri/version/info.rb +223 -0
- data/lib/nokogiri/version.rb +4 -0
- data/lib/nokogiri/xml/attr.rb +66 -0
- data/lib/nokogiri/xml/attribute_decl.rb +20 -0
- data/lib/nokogiri/xml/builder.rb +487 -0
- data/lib/nokogiri/xml/cdata.rb +13 -0
- data/lib/nokogiri/xml/character_data.rb +9 -0
- data/lib/nokogiri/xml/document.rb +471 -0
- data/lib/nokogiri/xml/document_fragment.rb +205 -0
- data/lib/nokogiri/xml/dtd.rb +34 -0
- data/lib/nokogiri/xml/element_content.rb +38 -0
- data/lib/nokogiri/xml/element_decl.rb +15 -0
- data/lib/nokogiri/xml/entity_decl.rb +21 -0
- data/lib/nokogiri/xml/entity_reference.rb +20 -0
- data/lib/nokogiri/xml/namespace.rb +58 -0
- data/lib/nokogiri/xml/node/save_options.rb +68 -0
- data/lib/nokogiri/xml/node.rb +1563 -0
- data/lib/nokogiri/xml/node_set.rb +446 -0
- data/lib/nokogiri/xml/notation.rb +19 -0
- data/lib/nokogiri/xml/parse_options.rb +213 -0
- data/lib/nokogiri/xml/pp/character_data.rb +21 -0
- data/lib/nokogiri/xml/pp/node.rb +57 -0
- data/lib/nokogiri/xml/pp.rb +4 -0
- data/lib/nokogiri/xml/processing_instruction.rb +11 -0
- data/lib/nokogiri/xml/reader.rb +105 -0
- data/lib/nokogiri/xml/relax_ng.rb +38 -0
- data/lib/nokogiri/xml/sax/document.rb +167 -0
- data/lib/nokogiri/xml/sax/parser.rb +125 -0
- data/lib/nokogiri/xml/sax/parser_context.rb +21 -0
- data/lib/nokogiri/xml/sax/push_parser.rb +61 -0
- data/lib/nokogiri/xml/sax.rb +6 -0
- data/lib/nokogiri/xml/schema.rb +73 -0
- data/lib/nokogiri/xml/searchable.rb +270 -0
- data/lib/nokogiri/xml/syntax_error.rb +72 -0
- data/lib/nokogiri/xml/text.rb +11 -0
- data/lib/nokogiri/xml/xpath/syntax_error.rb +13 -0
- data/lib/nokogiri/xml/xpath.rb +21 -0
- data/lib/nokogiri/xml/xpath_context.rb +16 -0
- data/lib/nokogiri/xml.rb +76 -0
- data/lib/nokogiri/xslt/stylesheet.rb +27 -0
- data/lib/nokogiri/xslt.rb +65 -0
- data/lib/nokogiri.rb +120 -0
- data/lib/xsd/xmlparser/nokogiri.rb +106 -0
- metadata +317 -0
@@ -0,0 +1,103 @@
|
|
1
|
+
#include <nokogiri.h>
|
2
|
+
|
3
|
+
VALUE cNokogiriXmlAttr;
|
4
|
+
|
5
|
+
/*
|
6
|
+
* call-seq:
|
7
|
+
* value=(content)
|
8
|
+
*
|
9
|
+
* Set the value for this Attr to +content+. Use `nil` to remove the value
|
10
|
+
* (e.g., a HTML boolean attribute).
|
11
|
+
*/
|
12
|
+
static VALUE
|
13
|
+
set_value(VALUE self, VALUE content)
|
14
|
+
{
|
15
|
+
xmlAttrPtr attr;
|
16
|
+
xmlChar *value;
|
17
|
+
xmlNode *cur;
|
18
|
+
|
19
|
+
Noko_Node_Get_Struct(self, xmlAttr, attr);
|
20
|
+
|
21
|
+
if (attr->children) {
|
22
|
+
xmlFreeNodeList(attr->children);
|
23
|
+
}
|
24
|
+
attr->children = attr->last = NULL;
|
25
|
+
|
26
|
+
if (content == Qnil) {
|
27
|
+
return content;
|
28
|
+
}
|
29
|
+
|
30
|
+
value = xmlEncodeEntitiesReentrant(attr->doc, (unsigned char *)StringValueCStr(content));
|
31
|
+
if (xmlStrlen(value) == 0) {
|
32
|
+
attr->children = xmlNewDocText(attr->doc, value);
|
33
|
+
} else {
|
34
|
+
attr->children = xmlStringGetNodeList(attr->doc, value);
|
35
|
+
}
|
36
|
+
xmlFree(value);
|
37
|
+
|
38
|
+
for (cur = attr->children; cur; cur = cur->next) {
|
39
|
+
cur->parent = (xmlNode *)attr;
|
40
|
+
cur->doc = attr->doc;
|
41
|
+
if (cur->next == NULL) {
|
42
|
+
attr->last = cur;
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
return content;
|
47
|
+
}
|
48
|
+
|
49
|
+
/*
|
50
|
+
* call-seq:
|
51
|
+
* new(document, name)
|
52
|
+
*
|
53
|
+
* Create a new Attr element on the +document+ with +name+
|
54
|
+
*/
|
55
|
+
static VALUE
|
56
|
+
new (int argc, VALUE *argv, VALUE klass)
|
57
|
+
{
|
58
|
+
xmlDocPtr xml_doc;
|
59
|
+
VALUE document;
|
60
|
+
VALUE name;
|
61
|
+
VALUE rest;
|
62
|
+
xmlAttrPtr node;
|
63
|
+
VALUE rb_node;
|
64
|
+
|
65
|
+
rb_scan_args(argc, argv, "2*", &document, &name, &rest);
|
66
|
+
|
67
|
+
if (! rb_obj_is_kind_of(document, cNokogiriXmlDocument)) {
|
68
|
+
rb_raise(rb_eArgError, "parameter must be a Nokogiri::XML::Document");
|
69
|
+
}
|
70
|
+
|
71
|
+
Noko_Node_Get_Struct(document, xmlDoc, xml_doc);
|
72
|
+
|
73
|
+
node = xmlNewDocProp(
|
74
|
+
xml_doc,
|
75
|
+
(const xmlChar *)StringValueCStr(name),
|
76
|
+
NULL
|
77
|
+
);
|
78
|
+
|
79
|
+
noko_xml_document_pin_node((xmlNodePtr)node);
|
80
|
+
|
81
|
+
rb_node = noko_xml_node_wrap(klass, (xmlNodePtr)node);
|
82
|
+
rb_obj_call_init(rb_node, argc, argv);
|
83
|
+
|
84
|
+
if (rb_block_given_p()) {
|
85
|
+
rb_yield(rb_node);
|
86
|
+
}
|
87
|
+
|
88
|
+
return rb_node;
|
89
|
+
}
|
90
|
+
|
91
|
+
void
|
92
|
+
noko_init_xml_attr()
|
93
|
+
{
|
94
|
+
assert(cNokogiriXmlNode);
|
95
|
+
/*
|
96
|
+
* Attr represents a Attr node in an xml document.
|
97
|
+
*/
|
98
|
+
cNokogiriXmlAttr = rb_define_class_under(mNokogiriXml, "Attr", cNokogiriXmlNode);
|
99
|
+
|
100
|
+
rb_define_singleton_method(cNokogiriXmlAttr, "new", new, -1);
|
101
|
+
|
102
|
+
rb_define_method(cNokogiriXmlAttr, "value=", set_value, 1);
|
103
|
+
}
|
@@ -0,0 +1,70 @@
|
|
1
|
+
#include <nokogiri.h>
|
2
|
+
|
3
|
+
VALUE cNokogiriXmlAttributeDecl;
|
4
|
+
|
5
|
+
/*
|
6
|
+
* call-seq:
|
7
|
+
* attribute_type
|
8
|
+
*
|
9
|
+
* The attribute_type for this AttributeDecl
|
10
|
+
*/
|
11
|
+
static VALUE
|
12
|
+
attribute_type(VALUE self)
|
13
|
+
{
|
14
|
+
xmlAttributePtr node;
|
15
|
+
Noko_Node_Get_Struct(self, xmlAttribute, node);
|
16
|
+
return INT2NUM(node->atype);
|
17
|
+
}
|
18
|
+
|
19
|
+
/*
|
20
|
+
* call-seq:
|
21
|
+
* default
|
22
|
+
*
|
23
|
+
* The default value
|
24
|
+
*/
|
25
|
+
static VALUE
|
26
|
+
default_value(VALUE self)
|
27
|
+
{
|
28
|
+
xmlAttributePtr node;
|
29
|
+
Noko_Node_Get_Struct(self, xmlAttribute, node);
|
30
|
+
|
31
|
+
if (node->defaultValue) { return NOKOGIRI_STR_NEW2(node->defaultValue); }
|
32
|
+
return Qnil;
|
33
|
+
}
|
34
|
+
|
35
|
+
/*
|
36
|
+
* call-seq:
|
37
|
+
* enumeration
|
38
|
+
*
|
39
|
+
* An enumeration of possible values
|
40
|
+
*/
|
41
|
+
static VALUE
|
42
|
+
enumeration(VALUE self)
|
43
|
+
{
|
44
|
+
xmlAttributePtr node;
|
45
|
+
xmlEnumerationPtr enm;
|
46
|
+
VALUE list;
|
47
|
+
|
48
|
+
Noko_Node_Get_Struct(self, xmlAttribute, node);
|
49
|
+
|
50
|
+
list = rb_ary_new();
|
51
|
+
enm = node->tree;
|
52
|
+
|
53
|
+
while (enm) {
|
54
|
+
rb_ary_push(list, NOKOGIRI_STR_NEW2(enm->name));
|
55
|
+
enm = enm->next;
|
56
|
+
}
|
57
|
+
|
58
|
+
return list;
|
59
|
+
}
|
60
|
+
|
61
|
+
void
|
62
|
+
noko_init_xml_attribute_decl()
|
63
|
+
{
|
64
|
+
assert(cNokogiriXmlNode);
|
65
|
+
cNokogiriXmlAttributeDecl = rb_define_class_under(mNokogiriXml, "AttributeDecl", cNokogiriXmlNode);
|
66
|
+
|
67
|
+
rb_define_method(cNokogiriXmlAttributeDecl, "attribute_type", attribute_type, 0);
|
68
|
+
rb_define_method(cNokogiriXmlAttributeDecl, "default", default_value, 0);
|
69
|
+
rb_define_method(cNokogiriXmlAttributeDecl, "enumeration", enumeration, 0);
|
70
|
+
}
|
@@ -0,0 +1,57 @@
|
|
1
|
+
#include <nokogiri.h>
|
2
|
+
|
3
|
+
VALUE cNokogiriXmlCData;
|
4
|
+
|
5
|
+
/*
|
6
|
+
* call-seq:
|
7
|
+
* new(document, content)
|
8
|
+
*
|
9
|
+
* Create a new CDATA element on the +document+ with +content+
|
10
|
+
*
|
11
|
+
* If +content+ cannot be implicitly converted to a string, this method will
|
12
|
+
* raise a TypeError exception.
|
13
|
+
*/
|
14
|
+
static VALUE
|
15
|
+
new (int argc, VALUE *argv, VALUE klass)
|
16
|
+
{
|
17
|
+
xmlDocPtr xml_doc;
|
18
|
+
xmlNodePtr node;
|
19
|
+
VALUE doc;
|
20
|
+
VALUE content;
|
21
|
+
VALUE rest;
|
22
|
+
VALUE rb_node;
|
23
|
+
xmlChar *content_str = NULL;
|
24
|
+
int content_str_len = 0;
|
25
|
+
|
26
|
+
rb_scan_args(argc, argv, "2*", &doc, &content, &rest);
|
27
|
+
|
28
|
+
Noko_Node_Get_Struct(doc, xmlDoc, xml_doc);
|
29
|
+
|
30
|
+
if (!NIL_P(content)) {
|
31
|
+
content_str = (xmlChar *)StringValuePtr(content);
|
32
|
+
content_str_len = RSTRING_LENINT(content);
|
33
|
+
}
|
34
|
+
|
35
|
+
node = xmlNewCDataBlock(xml_doc->doc, content_str, content_str_len);
|
36
|
+
|
37
|
+
noko_xml_document_pin_node(node);
|
38
|
+
|
39
|
+
rb_node = noko_xml_node_wrap(klass, node);
|
40
|
+
rb_obj_call_init(rb_node, argc, argv);
|
41
|
+
|
42
|
+
if (rb_block_given_p()) { rb_yield(rb_node); }
|
43
|
+
|
44
|
+
return rb_node;
|
45
|
+
}
|
46
|
+
|
47
|
+
void
|
48
|
+
noko_init_xml_cdata()
|
49
|
+
{
|
50
|
+
assert(cNokogiriXmlText);
|
51
|
+
/*
|
52
|
+
* CData represents a CData node in an xml document.
|
53
|
+
*/
|
54
|
+
cNokogiriXmlCData = rb_define_class_under(mNokogiriXml, "CDATA", cNokogiriXmlText);
|
55
|
+
|
56
|
+
rb_define_singleton_method(cNokogiriXmlCData, "new", new, -1);
|
57
|
+
}
|
@@ -0,0 +1,62 @@
|
|
1
|
+
#include <nokogiri.h>
|
2
|
+
|
3
|
+
VALUE cNokogiriXmlComment;
|
4
|
+
|
5
|
+
static ID document_id ;
|
6
|
+
|
7
|
+
/*
|
8
|
+
* call-seq:
|
9
|
+
* new(document_or_node, content)
|
10
|
+
*
|
11
|
+
* Create a new Comment element on the +document+ with +content+.
|
12
|
+
* Alternatively, if a +node+ is passed, the +node+'s document is used.
|
13
|
+
*/
|
14
|
+
static VALUE
|
15
|
+
new (int argc, VALUE *argv, VALUE klass)
|
16
|
+
{
|
17
|
+
xmlDocPtr xml_doc;
|
18
|
+
xmlNodePtr node;
|
19
|
+
VALUE document;
|
20
|
+
VALUE content;
|
21
|
+
VALUE rest;
|
22
|
+
VALUE rb_node;
|
23
|
+
|
24
|
+
rb_scan_args(argc, argv, "2*", &document, &content, &rest);
|
25
|
+
|
26
|
+
if (rb_obj_is_kind_of(document, cNokogiriXmlNode)) {
|
27
|
+
document = rb_funcall(document, document_id, 0);
|
28
|
+
} else if (!rb_obj_is_kind_of(document, cNokogiriXmlDocument)
|
29
|
+
&& !rb_obj_is_kind_of(document, cNokogiriXmlDocumentFragment)) {
|
30
|
+
rb_raise(rb_eArgError, "first argument must be a XML::Document or XML::Node");
|
31
|
+
}
|
32
|
+
|
33
|
+
Data_Get_Struct(document, xmlDoc, xml_doc);
|
34
|
+
|
35
|
+
node = xmlNewDocComment(
|
36
|
+
xml_doc,
|
37
|
+
(const xmlChar *)StringValueCStr(content)
|
38
|
+
);
|
39
|
+
|
40
|
+
rb_node = noko_xml_node_wrap(klass, node);
|
41
|
+
rb_obj_call_init(rb_node, argc, argv);
|
42
|
+
|
43
|
+
noko_xml_document_pin_node(node);
|
44
|
+
|
45
|
+
if (rb_block_given_p()) { rb_yield(rb_node); }
|
46
|
+
|
47
|
+
return rb_node;
|
48
|
+
}
|
49
|
+
|
50
|
+
void
|
51
|
+
noko_init_xml_comment()
|
52
|
+
{
|
53
|
+
assert(cNokogiriXmlCharacterData);
|
54
|
+
/*
|
55
|
+
* Comment represents a comment node in an xml document.
|
56
|
+
*/
|
57
|
+
cNokogiriXmlComment = rb_define_class_under(mNokogiriXml, "Comment", cNokogiriXmlCharacterData);
|
58
|
+
|
59
|
+
rb_define_singleton_method(cNokogiriXmlComment, "new", new, -1);
|
60
|
+
|
61
|
+
document_id = rb_intern("document");
|
62
|
+
}
|