nokogiri 1.13.0-x64-mingw-ucrt
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of nokogiri might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/Gemfile +5 -0
- data/LICENSE-DEPENDENCIES.md +1903 -0
- data/LICENSE.md +9 -0
- data/README.md +280 -0
- data/bin/nokogiri +131 -0
- data/dependencies.yml +73 -0
- data/ext/nokogiri/depend +38 -0
- data/ext/nokogiri/extconf.rb +1000 -0
- data/ext/nokogiri/gumbo.c +584 -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 +120 -0
- data/ext/nokogiri/html4_sax_push_parser.c +95 -0
- data/ext/nokogiri/include/libexslt/exslt.h +102 -0
- data/ext/nokogiri/include/libexslt/exsltconfig.h +70 -0
- data/ext/nokogiri/include/libexslt/exsltexports.h +140 -0
- data/ext/nokogiri/include/libxml2/libxml/DOCBparser.h +96 -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 +173 -0
- data/ext/nokogiri/include/libxml2/libxml/SAX2.h +178 -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 +79 -0
- data/ext/nokogiri/include/libxml2/libxml/encoding.h +245 -0
- data/ext/nokogiri/include/libxml2/libxml/entities.h +151 -0
- data/ext/nokogiri/include/libxml2/libxml/globals.h +508 -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 +163 -0
- data/ext/nokogiri/include/libxml2/libxml/nanohttp.h +81 -0
- data/ext/nokogiri/include/libxml2/libxml/parser.h +1243 -0
- data/ext/nokogiri/include/libxml2/libxml/parserInternals.h +644 -0
- data/ext/nokogiri/include/libxml2/libxml/pattern.h +100 -0
- data/ext/nokogiri/include/libxml2/libxml/relaxng.h +217 -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 +89 -0
- data/ext/nokogiri/include/libxml2/libxml/tree.h +1311 -0
- data/ext/nokogiri/include/libxml2/libxml/uri.h +94 -0
- data/ext/nokogiri/include/libxml2/libxml/valid.h +458 -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 +946 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlexports.h +77 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlmemory.h +224 -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 +151 -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 +485 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlwriter.h +488 -0
- data/ext/nokogiri/include/libxml2/libxml/xpath.h +564 -0
- data/ext/nokogiri/include/libxml2/libxml/xpathInternals.h +632 -0
- data/ext/nokogiri/include/libxml2/libxml/xpointer.h +114 -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 +1978 -0
- data/ext/nokogiri/include/libxslt/xsltconfig.h +180 -0
- data/ext/nokogiri/include/libxslt/xsltexports.h +142 -0
- data/ext/nokogiri/include/libxslt/xsltlocale.h +76 -0
- data/ext/nokogiri/include/libxslt/xsltutils.h +313 -0
- data/ext/nokogiri/libxml2_backwards_compat.c +121 -0
- data/ext/nokogiri/nokogiri.c +278 -0
- data/ext/nokogiri/nokogiri.h +223 -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 +680 -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 +120 -0
- data/ext/nokogiri/xml_node.c +2144 -0
- data/ext/nokogiri/xml_node_set.c +498 -0
- data/ext/nokogiri/xml_processing_instruction.c +54 -0
- data/ext/nokogiri/xml_reader.c +719 -0
- data/ext/nokogiri/xml_relax_ng.c +185 -0
- data/ext/nokogiri/xml_sax_parser.c +310 -0
- data/ext/nokogiri/xml_sax_parser_context.c +281 -0
- data/ext/nokogiri/xml_sax_push_parser.c +168 -0
- data/ext/nokogiri/xml_schema.c +284 -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 +406 -0
- data/ext/nokogiri/xslt_stylesheet.c +264 -0
- data/gumbo-parser/CHANGES.md +63 -0
- data/gumbo-parser/Makefile +101 -0
- data/gumbo-parser/THANKS +27 -0
- data/lib/nokogiri/3.1/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 +759 -0
- data/lib/nokogiri/css/parser.y +280 -0
- data/lib/nokogiri/css/parser_extras.rb +94 -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 +60 -0
- data/lib/nokogiri/decorators/slop.rb +44 -0
- data/lib/nokogiri/extension.rb +31 -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 +331 -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 +578 -0
- data/lib/nokogiri/html4/entity_lookup.rb +15 -0
- data/lib/nokogiri/html4/sax/parser.rb +61 -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 +46 -0
- data/lib/nokogiri/html5/document.rb +88 -0
- data/lib/nokogiri/html5/document_fragment.rb +83 -0
- data/lib/nokogiri/html5/node.rb +96 -0
- data/lib/nokogiri/html5.rb +477 -0
- data/lib/nokogiri/jruby/dependencies.rb +21 -0
- data/lib/nokogiri/syntax_error.rb +6 -0
- data/lib/nokogiri/version/constant.rb +6 -0
- data/lib/nokogiri/version/info.rb +221 -0
- data/lib/nokogiri/version.rb +4 -0
- data/lib/nokogiri/xml/attr.rb +17 -0
- data/lib/nokogiri/xml/attribute_decl.rb +20 -0
- data/lib/nokogiri/xml/builder.rb +485 -0
- data/lib/nokogiri/xml/cdata.rb +13 -0
- data/lib/nokogiri/xml/character_data.rb +9 -0
- data/lib/nokogiri/xml/document.rb +418 -0
- data/lib/nokogiri/xml/document_fragment.rb +162 -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 +16 -0
- data/lib/nokogiri/xml/node/save_options.rb +65 -0
- data/lib/nokogiri/xml/node.rb +1402 -0
- data/lib/nokogiri/xml/node_set.rb +364 -0
- data/lib/nokogiri/xml/notation.rb +19 -0
- data/lib/nokogiri/xml/parse_options.rb +133 -0
- data/lib/nokogiri/xml/pp/character_data.rb +21 -0
- data/lib/nokogiri/xml/pp/node.rb +55 -0
- data/lib/nokogiri/xml/pp.rb +4 -0
- data/lib/nokogiri/xml/processing_instruction.rb +10 -0
- data/lib/nokogiri/xml/reader.rb +107 -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 +259 -0
- data/lib/nokogiri/xml/syntax_error.rb +71 -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 +75 -0
- data/lib/nokogiri/xslt/stylesheet.rb +27 -0
- data/lib/nokogiri/xslt.rb +58 -0
- data/lib/nokogiri.rb +128 -0
- data/lib/xsd/xmlparser/nokogiri.rb +104 -0
- metadata +536 -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
|
+
Data_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
|
+
Data_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
|
+
Data_Get_Struct(self, xmlAttribute, node);
|
16
|
+
return INT2NUM((long)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
|
+
Data_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
|
+
Data_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
|
+
Data_Get_Struct(doc, xmlDoc, xml_doc);
|
29
|
+
|
30
|
+
if (!NIL_P(content)) {
|
31
|
+
content_str = (xmlChar *)StringValuePtr(content);
|
32
|
+
content_str_len = RSTRING_LEN(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
|
+
}
|