mini-pro-gem 0.0.1
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.
- checksums.yaml +7 -0
- data/mini-pro-gem.gemspec +12 -0
- data/nokogiri-1.19.4/Gemfile +40 -0
- data/nokogiri-1.19.4/LICENSE-DEPENDENCIES.md +2411 -0
- data/nokogiri-1.19.4/LICENSE.md +9 -0
- data/nokogiri-1.19.4/README.md +308 -0
- data/nokogiri-1.19.4/bin/nokogiri +131 -0
- data/nokogiri-1.19.4/dependencies.yml +31 -0
- data/nokogiri-1.19.4/ext/nokogiri/depend +38 -0
- data/nokogiri-1.19.4/ext/nokogiri/extconf.rb +1165 -0
- data/nokogiri-1.19.4/ext/nokogiri/gumbo.c +610 -0
- data/nokogiri-1.19.4/ext/nokogiri/html4_document.c +171 -0
- data/nokogiri-1.19.4/ext/nokogiri/html4_element_description.c +299 -0
- data/nokogiri-1.19.4/ext/nokogiri/html4_entity_lookup.c +37 -0
- data/nokogiri-1.19.4/ext/nokogiri/html4_sax_parser.c +40 -0
- data/nokogiri-1.19.4/ext/nokogiri/html4_sax_parser_context.c +98 -0
- data/nokogiri-1.19.4/ext/nokogiri/html4_sax_push_parser.c +96 -0
- data/nokogiri-1.19.4/ext/nokogiri/libxml2_polyfill.c +114 -0
- data/nokogiri-1.19.4/ext/nokogiri/nokogiri.c +297 -0
- data/nokogiri-1.19.4/ext/nokogiri/nokogiri.h +247 -0
- data/nokogiri-1.19.4/ext/nokogiri/test_global_handlers.c +40 -0
- data/nokogiri-1.19.4/ext/nokogiri/xml_attr.c +108 -0
- data/nokogiri-1.19.4/ext/nokogiri/xml_attribute_decl.c +70 -0
- data/nokogiri-1.19.4/ext/nokogiri/xml_cdata.c +62 -0
- data/nokogiri-1.19.4/ext/nokogiri/xml_comment.c +57 -0
- data/nokogiri-1.19.4/ext/nokogiri/xml_document.c +796 -0
- data/nokogiri-1.19.4/ext/nokogiri/xml_document_fragment.c +29 -0
- data/nokogiri-1.19.4/ext/nokogiri/xml_dtd.c +208 -0
- data/nokogiri-1.19.4/ext/nokogiri/xml_element_content.c +131 -0
- data/nokogiri-1.19.4/ext/nokogiri/xml_element_decl.c +69 -0
- data/nokogiri-1.19.4/ext/nokogiri/xml_encoding_handler.c +112 -0
- data/nokogiri-1.19.4/ext/nokogiri/xml_entity_decl.c +112 -0
- data/nokogiri-1.19.4/ext/nokogiri/xml_entity_reference.c +50 -0
- data/nokogiri-1.19.4/ext/nokogiri/xml_namespace.c +181 -0
- data/nokogiri-1.19.4/ext/nokogiri/xml_node.c +2523 -0
- data/nokogiri-1.19.4/ext/nokogiri/xml_node_set.c +518 -0
- data/nokogiri-1.19.4/ext/nokogiri/xml_processing_instruction.c +54 -0
- data/nokogiri-1.19.4/ext/nokogiri/xml_reader.c +777 -0
- data/nokogiri-1.19.4/ext/nokogiri/xml_relax_ng.c +149 -0
- data/nokogiri-1.19.4/ext/nokogiri/xml_sax_parser.c +403 -0
- data/nokogiri-1.19.4/ext/nokogiri/xml_sax_parser_context.c +396 -0
- data/nokogiri-1.19.4/ext/nokogiri/xml_sax_push_parser.c +206 -0
- data/nokogiri-1.19.4/ext/nokogiri/xml_schema.c +226 -0
- data/nokogiri-1.19.4/ext/nokogiri/xml_syntax_error.c +93 -0
- data/nokogiri-1.19.4/ext/nokogiri/xml_text.c +59 -0
- data/nokogiri-1.19.4/ext/nokogiri/xml_xpath_context.c +496 -0
- data/nokogiri-1.19.4/ext/nokogiri/xslt_stylesheet.c +457 -0
- data/nokogiri-1.19.4/gumbo-parser/CHANGES.md +63 -0
- data/nokogiri-1.19.4/gumbo-parser/Makefile +129 -0
- data/nokogiri-1.19.4/gumbo-parser/THANKS +27 -0
- data/nokogiri-1.19.4/gumbo-parser/src/Makefile +34 -0
- data/nokogiri-1.19.4/gumbo-parser/src/README.md +41 -0
- data/nokogiri-1.19.4/gumbo-parser/src/ascii.c +75 -0
- data/nokogiri-1.19.4/gumbo-parser/src/ascii.h +115 -0
- data/nokogiri-1.19.4/gumbo-parser/src/attribute.c +42 -0
- data/nokogiri-1.19.4/gumbo-parser/src/attribute.h +17 -0
- data/nokogiri-1.19.4/gumbo-parser/src/char_ref.c +22225 -0
- data/nokogiri-1.19.4/gumbo-parser/src/char_ref.h +29 -0
- data/nokogiri-1.19.4/gumbo-parser/src/char_ref.rl +2154 -0
- data/nokogiri-1.19.4/gumbo-parser/src/error.c +658 -0
- data/nokogiri-1.19.4/gumbo-parser/src/error.h +152 -0
- data/nokogiri-1.19.4/gumbo-parser/src/foreign_attrs.c +103 -0
- data/nokogiri-1.19.4/gumbo-parser/src/foreign_attrs.gperf +27 -0
- data/nokogiri-1.19.4/gumbo-parser/src/insertion_mode.h +33 -0
- data/nokogiri-1.19.4/gumbo-parser/src/macros.h +91 -0
- data/nokogiri-1.19.4/gumbo-parser/src/nokogiri_gumbo.h +953 -0
- data/nokogiri-1.19.4/gumbo-parser/src/parser.c +4932 -0
- data/nokogiri-1.19.4/gumbo-parser/src/parser.h +41 -0
- data/nokogiri-1.19.4/gumbo-parser/src/replacement.h +33 -0
- data/nokogiri-1.19.4/gumbo-parser/src/string_buffer.c +103 -0
- data/nokogiri-1.19.4/gumbo-parser/src/string_buffer.h +68 -0
- data/nokogiri-1.19.4/gumbo-parser/src/string_piece.c +48 -0
- data/nokogiri-1.19.4/gumbo-parser/src/svg_attrs.c +174 -0
- data/nokogiri-1.19.4/gumbo-parser/src/svg_attrs.gperf +77 -0
- data/nokogiri-1.19.4/gumbo-parser/src/svg_tags.c +137 -0
- data/nokogiri-1.19.4/gumbo-parser/src/svg_tags.gperf +55 -0
- data/nokogiri-1.19.4/gumbo-parser/src/tag.c +223 -0
- data/nokogiri-1.19.4/gumbo-parser/src/tag_lookup.c +382 -0
- data/nokogiri-1.19.4/gumbo-parser/src/tag_lookup.gperf +170 -0
- data/nokogiri-1.19.4/gumbo-parser/src/tag_lookup.h +13 -0
- data/nokogiri-1.19.4/gumbo-parser/src/token_buffer.c +79 -0
- data/nokogiri-1.19.4/gumbo-parser/src/token_buffer.h +71 -0
- data/nokogiri-1.19.4/gumbo-parser/src/token_type.h +17 -0
- data/nokogiri-1.19.4/gumbo-parser/src/tokenizer.c +3464 -0
- data/nokogiri-1.19.4/gumbo-parser/src/tokenizer.h +112 -0
- data/nokogiri-1.19.4/gumbo-parser/src/tokenizer_states.h +339 -0
- data/nokogiri-1.19.4/gumbo-parser/src/utf8.c +245 -0
- data/nokogiri-1.19.4/gumbo-parser/src/utf8.h +164 -0
- data/nokogiri-1.19.4/gumbo-parser/src/util.c +66 -0
- data/nokogiri-1.19.4/gumbo-parser/src/util.h +34 -0
- data/nokogiri-1.19.4/gumbo-parser/src/vector.c +111 -0
- data/nokogiri-1.19.4/gumbo-parser/src/vector.h +45 -0
- data/nokogiri-1.19.4/lib/nokogiri/class_resolver.rb +65 -0
- data/nokogiri-1.19.4/lib/nokogiri/css/node.rb +58 -0
- data/nokogiri-1.19.4/lib/nokogiri/css/parser.rb +772 -0
- data/nokogiri-1.19.4/lib/nokogiri/css/parser.y +277 -0
- data/nokogiri-1.19.4/lib/nokogiri/css/parser_extras.rb +36 -0
- data/nokogiri-1.19.4/lib/nokogiri/css/selector_cache.rb +38 -0
- data/nokogiri-1.19.4/lib/nokogiri/css/syntax_error.rb +9 -0
- data/nokogiri-1.19.4/lib/nokogiri/css/tokenizer.rb +155 -0
- data/nokogiri-1.19.4/lib/nokogiri/css/tokenizer.rex +57 -0
- data/nokogiri-1.19.4/lib/nokogiri/css/xpath_visitor.rb +376 -0
- data/nokogiri-1.19.4/lib/nokogiri/css.rb +132 -0
- data/nokogiri-1.19.4/lib/nokogiri/decorators/slop.rb +42 -0
- data/nokogiri-1.19.4/lib/nokogiri/encoding_handler.rb +57 -0
- data/nokogiri-1.19.4/lib/nokogiri/extension.rb +32 -0
- data/nokogiri-1.19.4/lib/nokogiri/gumbo.rb +15 -0
- data/nokogiri-1.19.4/lib/nokogiri/html.rb +48 -0
- data/nokogiri-1.19.4/lib/nokogiri/html4/builder.rb +37 -0
- data/nokogiri-1.19.4/lib/nokogiri/html4/document.rb +235 -0
- data/nokogiri-1.19.4/lib/nokogiri/html4/document_fragment.rb +166 -0
- data/nokogiri-1.19.4/lib/nokogiri/html4/element_description.rb +25 -0
- data/nokogiri-1.19.4/lib/nokogiri/html4/element_description_defaults.rb +2040 -0
- data/nokogiri-1.19.4/lib/nokogiri/html4/encoding_reader.rb +121 -0
- data/nokogiri-1.19.4/lib/nokogiri/html4/entity_lookup.rb +15 -0
- data/nokogiri-1.19.4/lib/nokogiri/html4/sax/parser.rb +48 -0
- data/nokogiri-1.19.4/lib/nokogiri/html4/sax/parser_context.rb +15 -0
- data/nokogiri-1.19.4/lib/nokogiri/html4/sax/push_parser.rb +37 -0
- data/nokogiri-1.19.4/lib/nokogiri/html4.rb +42 -0
- data/nokogiri-1.19.4/lib/nokogiri/html5/builder.rb +40 -0
- data/nokogiri-1.19.4/lib/nokogiri/html5/document.rb +199 -0
- data/nokogiri-1.19.4/lib/nokogiri/html5/document_fragment.rb +200 -0
- data/nokogiri-1.19.4/lib/nokogiri/html5/node.rb +103 -0
- data/nokogiri-1.19.4/lib/nokogiri/html5.rb +368 -0
- data/nokogiri-1.19.4/lib/nokogiri/jruby/dependencies.rb +3 -0
- data/nokogiri-1.19.4/lib/nokogiri/jruby/nokogiri_jars.rb +48 -0
- data/nokogiri-1.19.4/lib/nokogiri/syntax_error.rb +6 -0
- data/nokogiri-1.19.4/lib/nokogiri/version/constant.rb +6 -0
- data/nokogiri-1.19.4/lib/nokogiri/version/info.rb +234 -0
- data/nokogiri-1.19.4/lib/nokogiri/version.rb +4 -0
- data/nokogiri-1.19.4/lib/nokogiri/xml/attr.rb +66 -0
- data/nokogiri-1.19.4/lib/nokogiri/xml/attribute_decl.rb +22 -0
- data/nokogiri-1.19.4/lib/nokogiri/xml/builder.rb +494 -0
- data/nokogiri-1.19.4/lib/nokogiri/xml/cdata.rb +13 -0
- data/nokogiri-1.19.4/lib/nokogiri/xml/character_data.rb +9 -0
- data/nokogiri-1.19.4/lib/nokogiri/xml/document.rb +515 -0
- data/nokogiri-1.19.4/lib/nokogiri/xml/document_fragment.rb +276 -0
- data/nokogiri-1.19.4/lib/nokogiri/xml/dtd.rb +34 -0
- data/nokogiri-1.19.4/lib/nokogiri/xml/element_content.rb +46 -0
- data/nokogiri-1.19.4/lib/nokogiri/xml/element_decl.rb +17 -0
- data/nokogiri-1.19.4/lib/nokogiri/xml/entity_decl.rb +23 -0
- data/nokogiri-1.19.4/lib/nokogiri/xml/entity_reference.rb +20 -0
- data/nokogiri-1.19.4/lib/nokogiri/xml/namespace.rb +57 -0
- data/nokogiri-1.19.4/lib/nokogiri/xml/node/save_options.rb +76 -0
- data/nokogiri-1.19.4/lib/nokogiri/xml/node.rb +1701 -0
- data/nokogiri-1.19.4/lib/nokogiri/xml/node_set.rb +449 -0
- data/nokogiri-1.19.4/lib/nokogiri/xml/notation.rb +19 -0
- data/nokogiri-1.19.4/lib/nokogiri/xml/parse_options.rb +217 -0
- data/nokogiri-1.19.4/lib/nokogiri/xml/pp/character_data.rb +21 -0
- data/nokogiri-1.19.4/lib/nokogiri/xml/pp/node.rb +73 -0
- data/nokogiri-1.19.4/lib/nokogiri/xml/pp.rb +4 -0
- data/nokogiri-1.19.4/lib/nokogiri/xml/processing_instruction.rb +11 -0
- data/nokogiri-1.19.4/lib/nokogiri/xml/reader.rb +139 -0
- data/nokogiri-1.19.4/lib/nokogiri/xml/relax_ng.rb +75 -0
- data/nokogiri-1.19.4/lib/nokogiri/xml/sax/document.rb +258 -0
- data/nokogiri-1.19.4/lib/nokogiri/xml/sax/parser.rb +199 -0
- data/nokogiri-1.19.4/lib/nokogiri/xml/sax/parser_context.rb +129 -0
- data/nokogiri-1.19.4/lib/nokogiri/xml/sax/push_parser.rb +64 -0
- data/nokogiri-1.19.4/lib/nokogiri/xml/sax.rb +54 -0
- data/nokogiri-1.19.4/lib/nokogiri/xml/schema.rb +140 -0
- data/nokogiri-1.19.4/lib/nokogiri/xml/searchable.rb +274 -0
- data/nokogiri-1.19.4/lib/nokogiri/xml/syntax_error.rb +94 -0
- data/nokogiri-1.19.4/lib/nokogiri/xml/text.rb +11 -0
- data/nokogiri-1.19.4/lib/nokogiri/xml/xpath/syntax_error.rb +13 -0
- data/nokogiri-1.19.4/lib/nokogiri/xml/xpath.rb +21 -0
- data/nokogiri-1.19.4/lib/nokogiri/xml/xpath_context.rb +27 -0
- data/nokogiri-1.19.4/lib/nokogiri/xml.rb +65 -0
- data/nokogiri-1.19.4/lib/nokogiri/xslt/stylesheet.rb +54 -0
- data/nokogiri-1.19.4/lib/nokogiri/xslt.rb +138 -0
- data/nokogiri-1.19.4/lib/nokogiri.rb +128 -0
- data/nokogiri-1.19.4/lib/xsd/xmlparser/nokogiri.rb +105 -0
- data/nokogiri-1.19.4/patches/libxml2/0001-Remove-script-macro-support.patch +40 -0
- data/nokogiri-1.19.4/patches/libxml2/0002-Update-entities-to-remove-handling-of-ssi.patch +44 -0
- data/nokogiri-1.19.4/patches/libxml2/0009-allow-wildcard-namespaces.patch +77 -0
- data/nokogiri-1.19.4/patches/libxml2/0010-update-config.guess-and-config.sub-for-libxml2.patch +224 -0
- data/nokogiri-1.19.4/patches/libxml2/0011-rip-out-libxml2-s-libc_single_threaded-support.patch +30 -0
- data/nokogiri-1.19.4/patches/libxml2/0019-xpath-Use-separate-static-hash-table-for-standard-fu.patch +244 -0
- data/nokogiri-1.19.4/patches/libxslt/0001-update-config.guess-and-config.sub-for-libxslt.patch +224 -0
- data/nokogiri-1.19.4/ports/archives/libxml2-2.13.9.tar.xz +0 -0
- data/nokogiri-1.19.4/ports/archives/libxslt-1.1.43.tar.xz +0 -0
- metadata +220 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
#ifndef NOKOGIRI_NATIVE
|
|
2
|
+
#define NOKOGIRI_NATIVE
|
|
3
|
+
|
|
4
|
+
#include <ruby/defines.h> // https://github.com/sparklemotion/nokogiri/issues/2696
|
|
5
|
+
|
|
6
|
+
#ifdef _MSC_VER
|
|
7
|
+
# ifndef WIN32_LEAN_AND_MEAN
|
|
8
|
+
# define WIN32_LEAN_AND_MEAN
|
|
9
|
+
# endif /* WIN32_LEAN_AND_MEAN */
|
|
10
|
+
|
|
11
|
+
# ifndef WIN32
|
|
12
|
+
# define WIN32
|
|
13
|
+
# endif /* WIN32 */
|
|
14
|
+
|
|
15
|
+
# include <winsock2.h>
|
|
16
|
+
# include <ws2tcpip.h>
|
|
17
|
+
# include <windows.h>
|
|
18
|
+
#endif
|
|
19
|
+
|
|
20
|
+
#ifdef _WIN32
|
|
21
|
+
# define NOKOPUBFUN __declspec(dllexport)
|
|
22
|
+
# define NOKOPUBVAR __declspec(dllexport) extern
|
|
23
|
+
#else
|
|
24
|
+
# define NOKOPUBFUN
|
|
25
|
+
# define NOKOPUBVAR extern
|
|
26
|
+
#endif
|
|
27
|
+
|
|
28
|
+
#include <stdlib.h>
|
|
29
|
+
#include <string.h>
|
|
30
|
+
#include <assert.h>
|
|
31
|
+
#include <stdarg.h>
|
|
32
|
+
#include <stdio.h>
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
#include <libxml/parser.h>
|
|
36
|
+
#include <libxml/tree.h>
|
|
37
|
+
#include <libxml/entities.h>
|
|
38
|
+
#include <libxml/xpath.h>
|
|
39
|
+
#include <libxml/xmlreader.h>
|
|
40
|
+
#include <libxml/xmlsave.h>
|
|
41
|
+
#include <libxml/xmlschemas.h>
|
|
42
|
+
#include <libxml/HTMLparser.h>
|
|
43
|
+
#include <libxml/HTMLtree.h>
|
|
44
|
+
#include <libxml/relaxng.h>
|
|
45
|
+
#include <libxml/xinclude.h>
|
|
46
|
+
#include <libxml/c14n.h>
|
|
47
|
+
#include <libxml/parserInternals.h>
|
|
48
|
+
#include <libxml/xpathInternals.h>
|
|
49
|
+
|
|
50
|
+
#include <libxslt/extensions.h>
|
|
51
|
+
#include <libxslt/xsltconfig.h>
|
|
52
|
+
#include <libxslt/xsltutils.h>
|
|
53
|
+
#include <libxslt/transform.h>
|
|
54
|
+
#include <libxslt/imports.h>
|
|
55
|
+
#include <libxslt/xsltInternals.h>
|
|
56
|
+
|
|
57
|
+
#include <libexslt/exslt.h>
|
|
58
|
+
|
|
59
|
+
/* libxml2_polyfill.c */
|
|
60
|
+
#ifndef HAVE_XMLCTXTSETOPTIONS
|
|
61
|
+
int xmlCtxtSetOptions(xmlParserCtxtPtr ctxt, int options);
|
|
62
|
+
#endif
|
|
63
|
+
#ifndef HAVE_XMLCTXTGETOPTIONS
|
|
64
|
+
int xmlCtxtGetOptions(xmlParserCtxtPtr ctxt);
|
|
65
|
+
#endif
|
|
66
|
+
#ifndef HAVE_XMLSWITCHENCODINGNAME
|
|
67
|
+
int xmlSwitchEncodingName(xmlParserCtxtPtr ctxt, const char *encoding);
|
|
68
|
+
#endif
|
|
69
|
+
|
|
70
|
+
#define XMLNS_PREFIX "xmlns"
|
|
71
|
+
#define XMLNS_PREFIX_LEN 6 /* including either colon or \0 */
|
|
72
|
+
|
|
73
|
+
#ifndef xmlErrorConstPtr
|
|
74
|
+
# if LIBXML_VERSION >= 21200
|
|
75
|
+
# define xmlErrorConstPtr const xmlError *
|
|
76
|
+
# else
|
|
77
|
+
# define xmlErrorConstPtr xmlError *
|
|
78
|
+
# endif
|
|
79
|
+
#endif
|
|
80
|
+
|
|
81
|
+
#include <ruby.h>
|
|
82
|
+
#include <ruby/st.h>
|
|
83
|
+
#include <ruby/encoding.h>
|
|
84
|
+
#include <ruby/util.h>
|
|
85
|
+
#include <ruby/version.h>
|
|
86
|
+
|
|
87
|
+
#define NOKOGIRI_STR_NEW2(str) NOKOGIRI_STR_NEW(str, strlen((const char *)(str)))
|
|
88
|
+
#define NOKOGIRI_STR_NEW(str, len) rb_external_str_new_with_enc((const char *)(str), (long)(len), rb_utf8_encoding())
|
|
89
|
+
#define RBSTR_OR_QNIL(_str) (_str ? NOKOGIRI_STR_NEW2(_str) : Qnil)
|
|
90
|
+
|
|
91
|
+
#ifndef NORETURN_DECL
|
|
92
|
+
# if defined(__GNUC__)
|
|
93
|
+
# define NORETURN_DECL __attribute__ ((noreturn))
|
|
94
|
+
# else
|
|
95
|
+
# define NORETURN_DECL
|
|
96
|
+
# endif
|
|
97
|
+
#endif
|
|
98
|
+
|
|
99
|
+
#ifndef PRINTFLIKE_DECL
|
|
100
|
+
# if defined(__GNUC__)
|
|
101
|
+
# define PRINTFLIKE_DECL(stringidx, argidx) __attribute__ ((format(printf,stringidx,argidx)))
|
|
102
|
+
# else
|
|
103
|
+
# define PRINTFLIKE_DECL(stringidx, argidx)
|
|
104
|
+
# endif
|
|
105
|
+
#endif
|
|
106
|
+
|
|
107
|
+
#if defined(TRUFFLERUBY) && !defined(NOKOGIRI_PACKAGED_LIBRARIES)
|
|
108
|
+
# define TRUFFLERUBY_NOKOGIRI_SYSTEM_LIBRARIES
|
|
109
|
+
#endif
|
|
110
|
+
|
|
111
|
+
NOKOPUBVAR VALUE mNokogiri ;
|
|
112
|
+
NOKOPUBVAR VALUE mNokogiriGumbo ;
|
|
113
|
+
NOKOPUBVAR VALUE mNokogiriHtml4 ;
|
|
114
|
+
NOKOPUBVAR VALUE mNokogiriHtml4Sax ;
|
|
115
|
+
NOKOPUBVAR VALUE mNokogiriHtml5 ;
|
|
116
|
+
NOKOPUBVAR VALUE mNokogiriXml ;
|
|
117
|
+
NOKOPUBVAR VALUE mNokogiriXmlSax ;
|
|
118
|
+
NOKOPUBVAR VALUE mNokogiriXmlXpath ;
|
|
119
|
+
NOKOPUBVAR VALUE mNokogiriXslt ;
|
|
120
|
+
|
|
121
|
+
NOKOPUBVAR VALUE cNokogiriEncodingHandler;
|
|
122
|
+
NOKOPUBVAR VALUE cNokogiriSyntaxError;
|
|
123
|
+
NOKOPUBVAR VALUE cNokogiriXmlAttr;
|
|
124
|
+
NOKOPUBVAR VALUE cNokogiriXmlAttributeDecl;
|
|
125
|
+
NOKOPUBVAR VALUE cNokogiriXmlCData;
|
|
126
|
+
NOKOPUBVAR VALUE cNokogiriXmlCharacterData;
|
|
127
|
+
NOKOPUBVAR VALUE cNokogiriXmlComment;
|
|
128
|
+
NOKOPUBVAR VALUE cNokogiriXmlDocument ;
|
|
129
|
+
NOKOPUBVAR VALUE cNokogiriXmlDocumentFragment;
|
|
130
|
+
NOKOPUBVAR VALUE cNokogiriXmlDtd;
|
|
131
|
+
NOKOPUBVAR VALUE cNokogiriXmlElement ;
|
|
132
|
+
NOKOPUBVAR VALUE cNokogiriXmlElementContent;
|
|
133
|
+
NOKOPUBVAR VALUE cNokogiriXmlElementDecl;
|
|
134
|
+
NOKOPUBVAR VALUE cNokogiriXmlEntityDecl;
|
|
135
|
+
NOKOPUBVAR VALUE cNokogiriXmlEntityReference;
|
|
136
|
+
NOKOPUBVAR VALUE cNokogiriXmlNamespace ;
|
|
137
|
+
NOKOPUBVAR VALUE cNokogiriXmlNode ;
|
|
138
|
+
NOKOPUBVAR VALUE cNokogiriXmlNodeSet ;
|
|
139
|
+
NOKOPUBVAR VALUE cNokogiriXmlProcessingInstruction;
|
|
140
|
+
NOKOPUBVAR VALUE cNokogiriXmlReader;
|
|
141
|
+
NOKOPUBVAR VALUE cNokogiriXmlRelaxNG;
|
|
142
|
+
NOKOPUBVAR VALUE cNokogiriXmlSaxParser ;
|
|
143
|
+
NOKOPUBVAR VALUE cNokogiriXmlSaxParserContext;
|
|
144
|
+
NOKOPUBVAR VALUE cNokogiriXmlSaxPushParser ;
|
|
145
|
+
NOKOPUBVAR VALUE cNokogiriXmlSchema;
|
|
146
|
+
NOKOPUBVAR VALUE cNokogiriXmlSyntaxError;
|
|
147
|
+
NOKOPUBVAR VALUE cNokogiriXmlText ;
|
|
148
|
+
NOKOPUBVAR VALUE cNokogiriXmlXpathContext;
|
|
149
|
+
NOKOPUBVAR VALUE cNokogiriXmlXpathSyntaxError;
|
|
150
|
+
NOKOPUBVAR VALUE cNokogiriXsltStylesheet ;
|
|
151
|
+
|
|
152
|
+
NOKOPUBVAR VALUE cNokogiriHtml4Document ;
|
|
153
|
+
NOKOPUBVAR VALUE cNokogiriHtml4SaxPushParser ;
|
|
154
|
+
NOKOPUBVAR VALUE cNokogiriHtml4ElementDescription ;
|
|
155
|
+
NOKOPUBVAR VALUE cNokogiriHtml4SaxParser;
|
|
156
|
+
NOKOPUBVAR VALUE cNokogiriHtml4SaxParserContext;
|
|
157
|
+
NOKOPUBVAR VALUE cNokogiriHtml5Document ;
|
|
158
|
+
|
|
159
|
+
typedef struct _nokogiriTuple {
|
|
160
|
+
VALUE doc;
|
|
161
|
+
st_table *unlinkedNodes;
|
|
162
|
+
VALUE node_cache;
|
|
163
|
+
} nokogiriTuple;
|
|
164
|
+
typedef nokogiriTuple *nokogiriTuplePtr;
|
|
165
|
+
|
|
166
|
+
typedef struct _libxmlStructuredErrorHandlerState {
|
|
167
|
+
void *user_data;
|
|
168
|
+
xmlStructuredErrorFunc handler;
|
|
169
|
+
} libxmlStructuredErrorHandlerState ;
|
|
170
|
+
|
|
171
|
+
typedef struct _nokogiriXsltStylesheetTuple {
|
|
172
|
+
xsltStylesheetPtr ss;
|
|
173
|
+
VALUE func_instances;
|
|
174
|
+
} nokogiriXsltStylesheetTuple;
|
|
175
|
+
|
|
176
|
+
void noko_xml_document_pin_node(xmlNodePtr);
|
|
177
|
+
void noko_xml_document_pin_namespace(xmlNsPtr, xmlDocPtr);
|
|
178
|
+
int noko_xml_document_has_wrapped_blank_nodes_p(xmlDocPtr c_document);
|
|
179
|
+
|
|
180
|
+
int noko_io_read(void *ctx, char *buffer, int len);
|
|
181
|
+
int noko_io_write(void *ctx, char *buffer, int len);
|
|
182
|
+
int noko_io_close(void *ctx);
|
|
183
|
+
|
|
184
|
+
static inline void *
|
|
185
|
+
_noko_data_ptr(VALUE rb_object)
|
|
186
|
+
{
|
|
187
|
+
void *c_data = DATA_PTR(rb_object);
|
|
188
|
+
if (c_data == NULL) {
|
|
189
|
+
rb_raise(rb_eRuntimeError, "Uninitialized %" PRIsVALUE " struct (null data pointer)", rb_obj_class(rb_object));
|
|
190
|
+
}
|
|
191
|
+
return c_data;
|
|
192
|
+
}
|
|
193
|
+
#define Noko_Node_Get_Struct(obj,type,sval) ((sval) = (type*)_noko_data_ptr(obj))
|
|
194
|
+
#define Noko_Namespace_Get_Struct(obj,type,sval) ((sval) = (type*)_noko_data_ptr(obj))
|
|
195
|
+
|
|
196
|
+
VALUE noko_xml_node_wrap(VALUE klass, xmlNodePtr node) ;
|
|
197
|
+
VALUE noko_xml_node_wrap_node_set_result(xmlNodePtr node, VALUE node_set) ;
|
|
198
|
+
VALUE noko_xml_node_attrs(xmlNodePtr node) ;
|
|
199
|
+
|
|
200
|
+
VALUE noko_xml_namespace_wrap(xmlNsPtr node, xmlDocPtr doc);
|
|
201
|
+
VALUE noko_xml_namespace_wrap_xpath_copy(xmlNsPtr node);
|
|
202
|
+
|
|
203
|
+
VALUE noko_xml_element_content_wrap(VALUE doc, xmlElementContentPtr element);
|
|
204
|
+
|
|
205
|
+
VALUE noko_xml_node_set_wrap(xmlNodeSetPtr node_set, VALUE document) ;
|
|
206
|
+
xmlNodeSetPtr noko_xml_node_set_unwrap(VALUE rb_node_set) ;
|
|
207
|
+
|
|
208
|
+
VALUE noko_xml_document_wrap_with_init_args(VALUE klass, xmlDocPtr doc, int argc, VALUE *argv);
|
|
209
|
+
VALUE noko_xml_document_wrap(VALUE klass, xmlDocPtr doc);
|
|
210
|
+
xmlDocPtr noko_xml_document_unwrap(VALUE rb_document);
|
|
211
|
+
NOKOPUBFUN VALUE Nokogiri_wrap_xml_document(VALUE klass,
|
|
212
|
+
xmlDocPtr doc); /* deprecated. use noko_xml_document_wrap() instead. */
|
|
213
|
+
|
|
214
|
+
xmlSAXHandlerPtr noko_xml_sax_parser_unwrap(VALUE rb_sax_handler);
|
|
215
|
+
|
|
216
|
+
xmlParserCtxtPtr noko_xml_sax_push_parser_unwrap(VALUE rb_parser);
|
|
217
|
+
|
|
218
|
+
VALUE noko_xml_sax_parser_context_wrap(VALUE klass, xmlParserCtxtPtr c_context);
|
|
219
|
+
xmlParserCtxtPtr noko_xml_sax_parser_context_unwrap(VALUE rb_context);
|
|
220
|
+
void noko_xml_sax_parser_context_set_encoding(xmlParserCtxtPtr c_context, VALUE rb_encoding);
|
|
221
|
+
|
|
222
|
+
#define DOC_RUBY_OBJECT_TEST(x) ((nokogiriTuplePtr)(x->_private))
|
|
223
|
+
#define DOC_RUBY_OBJECT(x) (((nokogiriTuplePtr)(x->_private))->doc)
|
|
224
|
+
#define DOC_UNLINKED_NODE_HASH(x) (((nokogiriTuplePtr)(x->_private))->unlinkedNodes)
|
|
225
|
+
#define DOC_NODE_CACHE(x) (((nokogiriTuplePtr)(x->_private))->node_cache)
|
|
226
|
+
#define NOKOGIRI_NAMESPACE_EH(node) ((node)->type == XML_NAMESPACE_DECL)
|
|
227
|
+
|
|
228
|
+
#define DISCARD_CONST_QUAL(t, v) ((t)(uintptr_t)(v))
|
|
229
|
+
#define DISCARD_CONST_QUAL_XMLCHAR(v) DISCARD_CONST_QUAL(xmlChar *, v)
|
|
230
|
+
|
|
231
|
+
#if HAVE_RB_CATEGORY_WARNING
|
|
232
|
+
# define NOKO_WARN_DEPRECATION(message...) rb_category_warning(RB_WARN_CATEGORY_DEPRECATED, message)
|
|
233
|
+
#else
|
|
234
|
+
# define NOKO_WARN_DEPRECATION(message...) rb_warning(message)
|
|
235
|
+
#endif
|
|
236
|
+
|
|
237
|
+
void noko__structured_error_func_save(libxmlStructuredErrorHandlerState *handler_state);
|
|
238
|
+
void noko__structured_error_func_save_and_set(libxmlStructuredErrorHandlerState *handler_state, void *user_data,
|
|
239
|
+
xmlStructuredErrorFunc handler);
|
|
240
|
+
void noko__structured_error_func_restore(libxmlStructuredErrorHandlerState *handler_state);
|
|
241
|
+
VALUE noko_xml_syntax_error__wrap(xmlErrorConstPtr error);
|
|
242
|
+
void noko__error_array_pusher(void *ctx, xmlErrorConstPtr error);
|
|
243
|
+
NORETURN_DECL void noko__error_raise(void *ctx, xmlErrorConstPtr error);
|
|
244
|
+
void Nokogiri_marshal_xpath_funcall_and_return_values(xmlXPathParserContextPtr ctx, int nargs, VALUE handler,
|
|
245
|
+
const char *function_name) ;
|
|
246
|
+
|
|
247
|
+
#endif /* NOKOGIRI_NATIVE */
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#include <nokogiri.h>
|
|
2
|
+
|
|
3
|
+
static VALUE foreign_error_handler_block = Qnil;
|
|
4
|
+
|
|
5
|
+
static void
|
|
6
|
+
foreign_error_handler(void *user_data, xmlErrorConstPtr c_error)
|
|
7
|
+
{
|
|
8
|
+
rb_funcall(foreign_error_handler_block, rb_intern("call"), 0);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/*
|
|
12
|
+
* call-seq:
|
|
13
|
+
* __foreign_error_handler { ... } -> nil
|
|
14
|
+
*
|
|
15
|
+
* Override libxml2's global error handlers to call the block. This method thus has very little
|
|
16
|
+
* value except to test that Nokogiri is properly setting error handlers elsewhere in the code. See
|
|
17
|
+
* test/helper.rb for how this is being used.
|
|
18
|
+
*/
|
|
19
|
+
static VALUE
|
|
20
|
+
rb_foreign_error_handler(VALUE klass)
|
|
21
|
+
{
|
|
22
|
+
rb_need_block();
|
|
23
|
+
foreign_error_handler_block = rb_block_proc();
|
|
24
|
+
xmlSetStructuredErrorFunc(NULL, foreign_error_handler);
|
|
25
|
+
return Qnil;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/*
|
|
29
|
+
* Document-module: Nokogiri::Test
|
|
30
|
+
*
|
|
31
|
+
* The Nokogiri::Test module should only be used for testing Nokogiri.
|
|
32
|
+
* Do NOT use this outside of the Nokogiri test suite.
|
|
33
|
+
*/
|
|
34
|
+
void
|
|
35
|
+
noko_init_test_global_handlers(void)
|
|
36
|
+
{
|
|
37
|
+
VALUE mNokogiriTest = rb_define_module_under(mNokogiri, "Test");
|
|
38
|
+
|
|
39
|
+
rb_define_singleton_method(mNokogiriTest, "__foreign_error_handler", rb_foreign_error_handler, 0);
|
|
40
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
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
|
+
noko_xml_attr_set_value(VALUE self, VALUE content)
|
|
14
|
+
{
|
|
15
|
+
xmlAttrPtr attr;
|
|
16
|
+
|
|
17
|
+
Noko_Node_Get_Struct(self, xmlAttr, attr);
|
|
18
|
+
|
|
19
|
+
{
|
|
20
|
+
/* Unlink and pin any wrapped children */
|
|
21
|
+
xmlNode *cur = attr->children;
|
|
22
|
+
xmlNode *next;
|
|
23
|
+
|
|
24
|
+
while (cur) {
|
|
25
|
+
next = cur->next;
|
|
26
|
+
if (cur->_private) {
|
|
27
|
+
xmlUnlinkNode(cur);
|
|
28
|
+
noko_xml_document_pin_node(cur);
|
|
29
|
+
}
|
|
30
|
+
cur = next;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (content == Qnil) {
|
|
35
|
+
xmlNodeSetContent((xmlNodePtr)attr, NULL); /* Clear any remaining unwrapped children. */
|
|
36
|
+
} else {
|
|
37
|
+
xmlChar *value = xmlEncodeEntitiesReentrant(attr->doc, (unsigned char *)StringValueCStr(content));
|
|
38
|
+
|
|
39
|
+
if (xmlStrlen(value) == 0) {
|
|
40
|
+
xmlNodeSetContent((xmlNodePtr)attr, NULL); /* Clear any remaining unwrapped children. */
|
|
41
|
+
|
|
42
|
+
/* Preserve empty-string attributes as `foo=""` and not boolean `foo` */
|
|
43
|
+
attr->children = attr->last = xmlNewDocText(attr->doc, value);
|
|
44
|
+
attr->children->parent = (xmlNode *)attr;
|
|
45
|
+
} else {
|
|
46
|
+
xmlNodeSetContent((xmlNodePtr)attr, value);
|
|
47
|
+
}
|
|
48
|
+
xmlFree(value);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return content;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/*
|
|
55
|
+
* call-seq:
|
|
56
|
+
* new(document, name)
|
|
57
|
+
*
|
|
58
|
+
* Create a new Attr element on the +document+ with +name+
|
|
59
|
+
*/
|
|
60
|
+
static VALUE
|
|
61
|
+
noko_xml_attr__new(int argc, VALUE *argv, VALUE klass)
|
|
62
|
+
{
|
|
63
|
+
xmlDocPtr xml_doc;
|
|
64
|
+
VALUE document;
|
|
65
|
+
VALUE name;
|
|
66
|
+
VALUE rest;
|
|
67
|
+
xmlAttrPtr node;
|
|
68
|
+
VALUE rb_node;
|
|
69
|
+
|
|
70
|
+
rb_scan_args(argc, argv, "2*", &document, &name, &rest);
|
|
71
|
+
|
|
72
|
+
if (! rb_obj_is_kind_of(document, cNokogiriXmlDocument)) {
|
|
73
|
+
rb_raise(rb_eArgError, "parameter must be a Nokogiri::XML::Document");
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
xml_doc = noko_xml_document_unwrap(document);
|
|
77
|
+
|
|
78
|
+
node = xmlNewDocProp(
|
|
79
|
+
xml_doc,
|
|
80
|
+
(const xmlChar *)StringValueCStr(name),
|
|
81
|
+
NULL
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
noko_xml_document_pin_node((xmlNodePtr)node);
|
|
85
|
+
|
|
86
|
+
rb_node = noko_xml_node_wrap(klass, (xmlNodePtr)node);
|
|
87
|
+
rb_obj_call_init(rb_node, argc, argv);
|
|
88
|
+
|
|
89
|
+
if (rb_block_given_p()) {
|
|
90
|
+
rb_yield(rb_node);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return rb_node;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
void
|
|
97
|
+
noko_init_xml_attr(void)
|
|
98
|
+
{
|
|
99
|
+
assert(cNokogiriXmlNode);
|
|
100
|
+
/*
|
|
101
|
+
* Attr represents a Attr node in an xml document.
|
|
102
|
+
*/
|
|
103
|
+
cNokogiriXmlAttr = rb_define_class_under(mNokogiriXml, "Attr", cNokogiriXmlNode);
|
|
104
|
+
|
|
105
|
+
rb_define_singleton_method(cNokogiriXmlAttr, "new", noko_xml_attr__new, -1);
|
|
106
|
+
|
|
107
|
+
rb_define_method(cNokogiriXmlAttr, "value=", noko_xml_attr_set_value, 1);
|
|
108
|
+
}
|
|
@@ -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(void)
|
|
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,62 @@
|
|
|
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
|
+
rb_xml_cdata_s_new(int argc, VALUE *argv, VALUE klass)
|
|
16
|
+
{
|
|
17
|
+
xmlDocPtr c_document;
|
|
18
|
+
xmlNodePtr c_node;
|
|
19
|
+
VALUE rb_document;
|
|
20
|
+
VALUE rb_content;
|
|
21
|
+
VALUE rb_rest;
|
|
22
|
+
VALUE rb_node;
|
|
23
|
+
|
|
24
|
+
rb_scan_args(argc, argv, "2*", &rb_document, &rb_content, &rb_rest);
|
|
25
|
+
|
|
26
|
+
Check_Type(rb_content, T_STRING);
|
|
27
|
+
if (!rb_obj_is_kind_of(rb_document, cNokogiriXmlNode)) {
|
|
28
|
+
rb_raise(rb_eTypeError,
|
|
29
|
+
"expected first parameter to be a Nokogiri::XML::Document, received %"PRIsVALUE,
|
|
30
|
+
rb_obj_class(rb_document));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (!rb_obj_is_kind_of(rb_document, cNokogiriXmlDocument)) {
|
|
34
|
+
xmlNodePtr deprecated_node_type_arg;
|
|
35
|
+
NOKO_WARN_DEPRECATION("Passing a Node as the first parameter to CDATA.new is deprecated. Please pass a Document instead. This will become an error in Nokogiri v1.17.0."); // TODO: deprecated in v1.15.3, remove in v1.17.0
|
|
36
|
+
Noko_Node_Get_Struct(rb_document, xmlNode, deprecated_node_type_arg);
|
|
37
|
+
c_document = deprecated_node_type_arg->doc;
|
|
38
|
+
} else {
|
|
39
|
+
c_document = noko_xml_document_unwrap(rb_document);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
c_node = xmlNewCDataBlock(c_document, (xmlChar *)StringValueCStr(rb_content), RSTRING_LENINT(rb_content));
|
|
43
|
+
noko_xml_document_pin_node(c_node);
|
|
44
|
+
rb_node = noko_xml_node_wrap(klass, c_node);
|
|
45
|
+
rb_obj_call_init(rb_node, argc, argv);
|
|
46
|
+
|
|
47
|
+
if (rb_block_given_p()) { rb_yield(rb_node); }
|
|
48
|
+
|
|
49
|
+
return rb_node;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
void
|
|
53
|
+
noko_init_xml_cdata(void)
|
|
54
|
+
{
|
|
55
|
+
assert(cNokogiriXmlText);
|
|
56
|
+
/*
|
|
57
|
+
* CData represents a CData node in an xml document.
|
|
58
|
+
*/
|
|
59
|
+
cNokogiriXmlCData = rb_define_class_under(mNokogiriXml, "CDATA", cNokogiriXmlText);
|
|
60
|
+
|
|
61
|
+
rb_define_singleton_method(cNokogiriXmlCData, "new", rb_xml_cdata_s_new, -1);
|
|
62
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
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
|
+
Check_Type(content, T_STRING);
|
|
27
|
+
if (rb_obj_is_kind_of(document, cNokogiriXmlNode)) {
|
|
28
|
+
document = rb_funcall(document, document_id, 0);
|
|
29
|
+
} else if (!rb_obj_is_kind_of(document, cNokogiriXmlDocument)
|
|
30
|
+
&& !rb_obj_is_kind_of(document, cNokogiriXmlDocumentFragment)) {
|
|
31
|
+
rb_raise(rb_eArgError, "first argument must be a XML::Document or XML::Node");
|
|
32
|
+
}
|
|
33
|
+
xml_doc = noko_xml_document_unwrap(document);
|
|
34
|
+
|
|
35
|
+
node = xmlNewDocComment(xml_doc, (const xmlChar *)StringValueCStr(content));
|
|
36
|
+
noko_xml_document_pin_node(node);
|
|
37
|
+
rb_node = noko_xml_node_wrap(klass, node);
|
|
38
|
+
rb_obj_call_init(rb_node, argc, argv);
|
|
39
|
+
|
|
40
|
+
if (rb_block_given_p()) { rb_yield(rb_node); }
|
|
41
|
+
|
|
42
|
+
return rb_node;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
void
|
|
46
|
+
noko_init_xml_comment(void)
|
|
47
|
+
{
|
|
48
|
+
assert(cNokogiriXmlCharacterData);
|
|
49
|
+
/*
|
|
50
|
+
* Comment represents a comment node in an xml document.
|
|
51
|
+
*/
|
|
52
|
+
cNokogiriXmlComment = rb_define_class_under(mNokogiriXml, "Comment", cNokogiriXmlCharacterData);
|
|
53
|
+
|
|
54
|
+
rb_define_singleton_method(cNokogiriXmlComment, "new", new, -1);
|
|
55
|
+
|
|
56
|
+
document_id = rb_intern("document");
|
|
57
|
+
}
|