nokogiri 1.11.7-arm64-darwin → 1.12.0-arm64-darwin

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.

Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE-DEPENDENCIES.md +243 -22
  3. data/LICENSE.md +1 -1
  4. data/README.md +6 -5
  5. data/ext/nokogiri/depend +35 -34
  6. data/ext/nokogiri/extconf.rb +181 -103
  7. data/ext/nokogiri/gumbo.c +584 -0
  8. data/ext/nokogiri/{html_document.c → html4_document.c} +8 -8
  9. data/ext/nokogiri/{html_element_description.c → html4_element_description.c} +20 -18
  10. data/ext/nokogiri/{html_entity_lookup.c → html4_entity_lookup.c} +7 -7
  11. data/ext/nokogiri/{html_sax_parser_context.c → html4_sax_parser_context.c} +5 -5
  12. data/ext/nokogiri/{html_sax_push_parser.c → html4_sax_push_parser.c} +4 -4
  13. data/ext/nokogiri/libxml2_backwards_compat.c +30 -30
  14. data/ext/nokogiri/nokogiri.c +51 -38
  15. data/ext/nokogiri/nokogiri.h +16 -9
  16. data/ext/nokogiri/xml_document.c +13 -13
  17. data/ext/nokogiri/xml_element_content.c +2 -0
  18. data/ext/nokogiri/xml_encoding_handler.c +11 -6
  19. data/ext/nokogiri/xml_namespace.c +2 -0
  20. data/ext/nokogiri/xml_node.c +102 -102
  21. data/ext/nokogiri/xml_node_set.c +20 -20
  22. data/ext/nokogiri/xml_reader.c +2 -0
  23. data/ext/nokogiri/xml_sax_parser.c +6 -6
  24. data/ext/nokogiri/xml_sax_parser_context.c +2 -0
  25. data/ext/nokogiri/xml_schema.c +2 -0
  26. data/ext/nokogiri/xml_xpath_context.c +67 -65
  27. data/ext/nokogiri/xslt_stylesheet.c +2 -1
  28. data/gumbo-parser/CHANGES.md +63 -0
  29. data/gumbo-parser/Makefile +101 -0
  30. data/gumbo-parser/THANKS +27 -0
  31. data/lib/nokogiri.rb +31 -29
  32. data/lib/nokogiri/2.5/nokogiri.bundle +0 -0
  33. data/lib/nokogiri/2.6/nokogiri.bundle +0 -0
  34. data/lib/nokogiri/2.7/nokogiri.bundle +0 -0
  35. data/lib/nokogiri/3.0/nokogiri.bundle +0 -0
  36. data/lib/nokogiri/css.rb +14 -14
  37. data/lib/nokogiri/css/parser.rb +1 -1
  38. data/lib/nokogiri/css/parser.y +1 -1
  39. data/lib/nokogiri/css/syntax_error.rb +1 -1
  40. data/lib/nokogiri/extension.rb +2 -2
  41. data/lib/nokogiri/gumbo.rb +14 -0
  42. data/lib/nokogiri/html.rb +31 -27
  43. data/lib/nokogiri/html4.rb +40 -0
  44. data/lib/nokogiri/{html → html4}/builder.rb +2 -2
  45. data/lib/nokogiri/{html → html4}/document.rb +4 -4
  46. data/lib/nokogiri/{html → html4}/document_fragment.rb +3 -3
  47. data/lib/nokogiri/{html → html4}/element_description.rb +1 -1
  48. data/lib/nokogiri/{html → html4}/element_description_defaults.rb +1 -1
  49. data/lib/nokogiri/{html → html4}/entity_lookup.rb +1 -1
  50. data/lib/nokogiri/{html → html4}/sax/parser.rb +11 -14
  51. data/lib/nokogiri/html4/sax/parser_context.rb +19 -0
  52. data/lib/nokogiri/{html → html4}/sax/push_parser.rb +5 -5
  53. data/lib/nokogiri/html5.rb +473 -0
  54. data/lib/nokogiri/html5/document.rb +74 -0
  55. data/lib/nokogiri/html5/document_fragment.rb +80 -0
  56. data/lib/nokogiri/html5/node.rb +93 -0
  57. data/lib/nokogiri/version/constant.rb +1 -1
  58. data/lib/nokogiri/version/info.rb +11 -2
  59. data/lib/nokogiri/xml.rb +35 -36
  60. data/lib/nokogiri/xml/node.rb +6 -5
  61. data/lib/nokogiri/xml/parse_options.rb +2 -0
  62. data/lib/nokogiri/xml/pp.rb +2 -2
  63. data/lib/nokogiri/xml/sax.rb +4 -4
  64. data/lib/nokogiri/xml/sax/document.rb +24 -30
  65. data/lib/nokogiri/xml/xpath.rb +2 -2
  66. data/lib/nokogiri/xslt.rb +16 -16
  67. data/lib/nokogiri/xslt/stylesheet.rb +1 -1
  68. metadata +35 -35
  69. data/lib/nokogiri/html/sax/parser_context.rb +0 -17
@@ -274,6 +274,8 @@ noko_init_xml_schema()
274
274
  {
275
275
  cNokogiriXmlSchema = rb_define_class_under(mNokogiriXml, "Schema", rb_cObject);
276
276
 
277
+ rb_undef_alloc_func(cNokogiriXmlSchema);
278
+
277
279
  rb_define_singleton_method(cNokogiriXmlSchema, "read_memory", read_memory, -1);
278
280
  rb_define_singleton_method(cNokogiriXmlSchema, "from_document", from_document, -1);
279
281
 
@@ -154,20 +154,20 @@ Nokogiri_marshal_xpath_funcall_and_return_values(xmlXPathParserContextPtr ctx, i
154
154
  do {
155
155
  obj = valuePop(ctx);
156
156
  switch (obj->type) {
157
- case XPATH_STRING:
158
- argv[i] = NOKOGIRI_STR_NEW2(obj->stringval);
159
- break;
160
- case XPATH_BOOLEAN:
161
- argv[i] = obj->boolval == 1 ? Qtrue : Qfalse;
162
- break;
163
- case XPATH_NUMBER:
164
- argv[i] = rb_float_new(obj->floatval);
165
- break;
166
- case XPATH_NODESET:
167
- argv[i] = noko_xml_node_set_wrap(obj->nodesetval, doc);
168
- break;
169
- default:
170
- argv[i] = NOKOGIRI_STR_NEW2(xmlXPathCastToString(obj));
157
+ case XPATH_STRING:
158
+ argv[i] = NOKOGIRI_STR_NEW2(obj->stringval);
159
+ break;
160
+ case XPATH_BOOLEAN:
161
+ argv[i] = obj->boolval == 1 ? Qtrue : Qfalse;
162
+ break;
163
+ case XPATH_NUMBER:
164
+ argv[i] = rb_float_new(obj->floatval);
165
+ break;
166
+ case XPATH_NODESET:
167
+ argv[i] = noko_xml_node_set_wrap(obj->nodesetval, doc);
168
+ break;
169
+ default:
170
+ argv[i] = NOKOGIRI_STR_NEW2(xmlXPathCastToString(obj));
171
171
  }
172
172
  xmlXPathFreeNodeSetList(obj);
173
173
  } while (i-- > 0);
@@ -181,43 +181,43 @@ Nokogiri_marshal_xpath_funcall_and_return_values(xmlXPathParserContextPtr ctx, i
181
181
  free(argv);
182
182
 
183
183
  switch (TYPE(result)) {
184
- case T_FLOAT:
185
- case T_BIGNUM:
186
- case T_FIXNUM:
187
- xmlXPathReturnNumber(ctx, NUM2DBL(result));
188
- break;
189
- case T_STRING:
190
- xmlXPathReturnString(
191
- ctx,
192
- xmlCharStrdup(StringValueCStr(result))
193
- );
194
- break;
195
- case T_TRUE:
196
- xmlXPathReturnTrue(ctx);
197
- break;
198
- case T_FALSE:
199
- xmlXPathReturnFalse(ctx);
200
- break;
201
- case T_NIL:
202
- break;
203
- case T_ARRAY: {
204
- VALUE args[2];
205
- args[0] = doc;
206
- args[1] = result;
207
- node_set = rb_class_new_instance(2, args, cNokogiriXmlNodeSet);
208
- Data_Get_Struct(node_set, xmlNodeSet, xml_node_set);
209
- xmlXPathReturnNodeSet(ctx, xmlXPathNodeSetMerge(NULL, xml_node_set));
210
- }
211
- break;
212
- case T_DATA:
213
- if (rb_obj_is_kind_of(result, cNokogiriXmlNodeSet)) {
214
- Data_Get_Struct(result, xmlNodeSet, xml_node_set);
215
- /* Copy the node set, otherwise it will get GC'd. */
216
- xmlXPathReturnNodeSet(ctx, xmlXPathNodeSetMerge(NULL, xml_node_set));
184
+ case T_FLOAT:
185
+ case T_BIGNUM:
186
+ case T_FIXNUM:
187
+ xmlXPathReturnNumber(ctx, NUM2DBL(result));
188
+ break;
189
+ case T_STRING:
190
+ xmlXPathReturnString(
191
+ ctx,
192
+ xmlCharStrdup(StringValueCStr(result))
193
+ );
194
+ break;
195
+ case T_TRUE:
196
+ xmlXPathReturnTrue(ctx);
197
+ break;
198
+ case T_FALSE:
199
+ xmlXPathReturnFalse(ctx);
217
200
  break;
201
+ case T_NIL:
202
+ break;
203
+ case T_ARRAY: {
204
+ VALUE args[2];
205
+ args[0] = doc;
206
+ args[1] = result;
207
+ node_set = rb_class_new_instance(2, args, cNokogiriXmlNodeSet);
208
+ Data_Get_Struct(node_set, xmlNodeSet, xml_node_set);
209
+ xmlXPathReturnNodeSet(ctx, xmlXPathNodeSetMerge(NULL, xml_node_set));
218
210
  }
219
- default:
220
- rb_raise(rb_eRuntimeError, "Invalid return type");
211
+ break;
212
+ case T_DATA:
213
+ if (rb_obj_is_kind_of(result, cNokogiriXmlNodeSet)) {
214
+ Data_Get_Struct(result, xmlNodeSet, xml_node_set);
215
+ /* Copy the node set, otherwise it will get GC'd. */
216
+ xmlXPathReturnNodeSet(ctx, xmlXPathNodeSetMerge(NULL, xml_node_set));
217
+ break;
218
+ }
219
+ default:
220
+ rb_raise(rb_eRuntimeError, "Invalid return type");
221
221
  }
222
222
  }
223
223
 
@@ -314,22 +314,22 @@ evaluate(int argc, VALUE *argv, VALUE self)
314
314
  assert(DOC_RUBY_OBJECT_TEST(ctx->doc));
315
315
 
316
316
  switch (xpath->type) {
317
- case XPATH_STRING:
318
- thing = NOKOGIRI_STR_NEW2(xpath->stringval);
319
- xmlFree(xpath->stringval);
320
- break;
321
- case XPATH_NODESET:
322
- thing = noko_xml_node_set_wrap(xpath->nodesetval,
323
- DOC_RUBY_OBJECT(ctx->doc));
324
- break;
325
- case XPATH_NUMBER:
326
- thing = rb_float_new(xpath->floatval);
327
- break;
328
- case XPATH_BOOLEAN:
329
- thing = xpath->boolval == 1 ? Qtrue : Qfalse;
330
- break;
331
- default:
332
- thing = noko_xml_node_set_wrap(NULL, DOC_RUBY_OBJECT(ctx->doc));
317
+ case XPATH_STRING:
318
+ thing = NOKOGIRI_STR_NEW2(xpath->stringval);
319
+ xmlFree(xpath->stringval);
320
+ break;
321
+ case XPATH_NODESET:
322
+ thing = noko_xml_node_set_wrap(xpath->nodesetval,
323
+ DOC_RUBY_OBJECT(ctx->doc));
324
+ break;
325
+ case XPATH_NUMBER:
326
+ thing = rb_float_new(xpath->floatval);
327
+ break;
328
+ case XPATH_BOOLEAN:
329
+ thing = xpath->boolval == 1 ? Qtrue : Qfalse;
330
+ break;
331
+ default:
332
+ thing = noko_xml_node_set_wrap(NULL, DOC_RUBY_OBJECT(ctx->doc));
333
333
  }
334
334
 
335
335
  xmlXPathFreeNodeSetList(xpath);
@@ -373,6 +373,8 @@ noko_init_xml_xpath_context(void)
373
373
  */
374
374
  cNokogiriXmlXpathContext = rb_define_class_under(mNokogiriXml, "XPathContext", rb_cObject);
375
375
 
376
+ rb_undef_alloc_func(cNokogiriXmlXpathContext);
377
+
376
378
  rb_define_singleton_method(cNokogiriXmlXpathContext, "new", new, 1);
377
379
 
378
380
  rb_define_method(cNokogiriXmlXpathContext, "evaluate", evaluate, -1);
@@ -64,7 +64,6 @@ parse_stylesheet_doc(VALUE klass, VALUE xmldocobj)
64
64
  VALUE errstr, exception;
65
65
  xsltStylesheetPtr ss ;
66
66
  Data_Get_Struct(xmldocobj, xmlDoc, xml);
67
- exsltRegisterAll();
68
67
 
69
68
  errstr = rb_str_new(0, 0);
70
69
  xsltSetGenericErrorFunc((void *)errstr, xslt_generic_error_handler);
@@ -257,6 +256,8 @@ noko_init_xslt_stylesheet()
257
256
 
258
257
  cNokogiriXsltStylesheet = rb_define_class_under(mNokogiriXslt, "Stylesheet", rb_cObject);
259
258
 
259
+ rb_undef_alloc_func(cNokogiriXsltStylesheet);
260
+
260
261
  rb_define_singleton_method(cNokogiriXsltStylesheet, "parse_stylesheet_doc", parse_stylesheet_doc, 1);
261
262
  rb_define_method(cNokogiriXsltStylesheet, "serialize", serialize, 1);
262
263
  rb_define_method(cNokogiriXsltStylesheet, "transform", transform, -1);
@@ -0,0 +1,63 @@
1
+ ## Gumbo 0.10.1 (2015-04-30)
2
+
3
+ Same as 0.10.0, but with the version number bumped because the last version-number commit to v0.9.4 makes GitHub think that v0.9.4 is the latest version and so it's not highlighted on the webpage.
4
+
5
+ ## Gumbo 0.10.0 (2015-04-30)
6
+
7
+ * Full support for `<template>` tag (kevinhendricks, nostrademons).
8
+ * Some fixes for `<rtc>`/`<rt>` handling (kevinhendricks, vmg).
9
+ * All html5lib-trunk tests pass now! (kevinhendricks, vmg, nostrademons)
10
+ * Support for fragment parsing (vmg)
11
+ * A couple additional example programs (kevinhendricks)
12
+ * Performance improvements totaling an estimated 30-40% total improvement (vmg, nostrademons).
13
+
14
+ ## Gumbo 0.9.4 (2015-04-30)
15
+
16
+ * Additional Visual Studio fixes (lowjoel, nostrademons)
17
+ * Fixed some unused variable warnings.
18
+ * Fix for glibtoolize vs. libtoolize build errors on Mac.
19
+ * Fixed `CDATA` end tag handling.
20
+
21
+ ## Gumbo 0.9.3 (2015-02-17)
22
+
23
+ * Bugfix for `&AElig;` entities (rgrove)
24
+ * Fix `CDATA` handling; `CDATA` sections now generate a `GUMBO_NODE_CDATA` node rather
25
+ than plain text.
26
+ * Fix `get_title example` to handle whitespace nodes (gsnedders)
27
+ * Visual Studio compilation fixes (fishioon)
28
+ * Take the namespace into account when determining whether a node matches a
29
+ certain tag (aroben)
30
+ * Replace the varargs tag functions with a tagset bytevector, for a 20-30%
31
+ speedup in overall parse time (kevinhendricks, vmg)
32
+ * Add MacOS X support to Travis CI, and fix the deployment/DLL issues this
33
+ uncovered (nostrademons, kevinhendricks, vmg)
34
+
35
+ ## Gumbo 0.9.2 (2014-09-21)
36
+
37
+ * Performance improvements: Ragel-based char ref decoder and DFA-based UTF8
38
+ decoder, totaling speedups of up to 300%.
39
+ * Added benchmarking program and some sample data.
40
+ * Fixed a compiler error under Visual Studio.
41
+ * Fix an error in the ctypes bindings that could lead to memory corruption in
42
+ the Python bindings.
43
+ * Fix duplicate attributes when parsing `<isindex>` tags.
44
+ * Don't leave semicolons behind when consuming entity references (rgrove)
45
+ * Internally rename some functions in preparation for an amalgamation file
46
+ (jdeng)
47
+ * Add proper cflags for gyp builds (skabbes)
48
+
49
+ ## Gumbo 0.9.1 (2014-08-07)
50
+
51
+ * First version listed on PyPi.
52
+ * Autotools files excluded from GitHub and generated via autogen.sh. (endgame)
53
+ * Numerous compiler warnings fixed. (bnoordhuis, craigbarnes)
54
+ * Google security audit passed.
55
+ * Gyp support (tfarina)
56
+ * Naming convention for structs changed to avoid C reserved words.
57
+ * Fix several integer and buffer overflows (Maxime2)
58
+ * Some Visual Studio compiler support (bugparty)
59
+ * Python3 compatibility for the ctypes bindings.
60
+
61
+ ## Gumbo 0.9.0 (2013-08-13)
62
+
63
+ * Initial release open-sourced by Google.
@@ -0,0 +1,101 @@
1
+ .PHONY: all clean check coverage
2
+
3
+ gumbo_objs := $(patsubst %.c,build/%.o,$(wildcard src/*.c))
4
+ test_objs := $(patsubst %.cc,build/%.o,$(wildcard test/*.cc))
5
+ gtest_lib := googletest/make/gtest_main.a
6
+
7
+ # make SANITIZEFLAGS='-fsanitize=undefined -fsanitize=address'
8
+ SANITIZEFLAGS :=
9
+ CPPFLAGS := -Isrc
10
+ CFLAGS := -std=c99 -Os -Wall
11
+ CXXFLAGS := -isystem googletest/include -std=c++11 -Os -Wall
12
+ LDFLAGS := -pthread
13
+
14
+ all: check
15
+
16
+ src/%.c: src/%.rl
17
+ ragel -F1 -o $@ $<
18
+
19
+ build/src:
20
+ mkdir -p $@
21
+
22
+ build/test:
23
+ mkdir -p $@
24
+
25
+ build/src/%.o: src/%.c build/src/flags | build/src
26
+ $(CC) -MMD $(CPPFLAGS) $(CFLAGS) $(SANITIZEFLAGS) -c -o $@ $<
27
+
28
+ build/test/%.o: test/%.cc build/test/flags | build/test
29
+ $(CXX) -MMD $(CPPFLAGS) $(CXXFLAGS) $(SANITIZEFLAGS) -c -o $@ $<
30
+
31
+ build/run_tests: $(gumbo_objs) $(test_objs) $(gtest_lib)
32
+ $(CXX) -o $@ $+ $(LDFLAGS) $(SANITIZEFLAGS)
33
+
34
+ check: build/run_tests
35
+ ./build/run_tests
36
+
37
+ coverage:
38
+ $(RM) build/{src,test}/*.gcda
39
+ $(RM) build/*.info
40
+ $(MAKE) CPPFLAGS='-Isrc -DNDEBUG=1' \
41
+ CFLAGS='-std=c99 --coverage -g -O0' \
42
+ CXXFLAGS='-isystem googletest/include -std=c++11 --coverage -g -O0' \
43
+ LDFLAGS='--coverage' \
44
+ build/run_tests
45
+ lcov --no-external \
46
+ --initial \
47
+ --capture \
48
+ --base-directory . \
49
+ --directory build \
50
+ --output-file build/coverage-pre.info
51
+ awk -F '[:,]' \
52
+ '/^SF:/ { delete defs } /^FN:/ { defs[$$2]=1 } /^DA:/ { if ($$3 == 0 && $$2 in defs) next } { print }' \
53
+ build/coverage-pre.info > build/coverage-initial.info
54
+ ./build/run_tests
55
+ lcov --no-external \
56
+ --capture \
57
+ --base-directory . \
58
+ --directory build \
59
+ --rc lcov_branch_coverage=1 \
60
+ --output-file build/coverage-test.info
61
+ lcov --add-tracefile build/coverage-initial.info \
62
+ --add-tracefile build/coverage-test.info \
63
+ --rc lcov_branch_coverage=1 \
64
+ --output-file build/coverage.info
65
+ lcov --remove build/coverage.info '$(CURDIR)/googletest/*' \
66
+ --rc lcov_branch_coverage=1 \
67
+ --output-file build/coverage.info
68
+ genhtml --branch-coverage \
69
+ --output-directory build/coverage \
70
+ build/coverage.info
71
+
72
+ clean:
73
+ $(RM) -r build
74
+
75
+ build/src/flags: | build/src
76
+ @echo 'old_CC := $(CC)' > $@
77
+ @echo 'old_CPPFLAGS := $(CPPFLAGS)' >> $@
78
+ @echo 'old_CFLAGS := $(CFLAGS)' >>$@
79
+ @echo 'old_SANITIZEFLAGS := $(SANITIZEFLAGS)' >> $@
80
+ @echo 'old_LDFLAGS := $(LDFLAGS)' >> $@
81
+
82
+ build/test/flags: | build/test
83
+ @echo 'old_CXX := $(CXX)' > $@
84
+ @echo 'old_CPPFLAGS := $(CPPFLAGS)' >> $@
85
+ @echo 'old_CXXFLAGS := $(CXXFLAGS)' >> $@
86
+ @echo 'old_SANITIZEFLAGS := $(SANITIZEFLAGS)' >> $@
87
+ @echo 'old_LDFLAGS := $(LDFLAGS)' >> $@
88
+
89
+ ifeq (,$(filter clean coverage,$(MAKECMDGOALS)))
90
+ # Ensure that the flags are up to date.
91
+ -include build/src/flags build/test/flags
92
+ ifneq ($(old_CC) | $(old_CPPFLAGS) | $(old_CFLAGS) | $(old_SANITIZEFLAGS) | $(old_LDFLAGS),$(CC) | $(CPPFLAGS) | $(CFLAGS) | $(SANITIZEFLAGS) | $(LDFLAGS))
93
+ .PHONY: build/src/flags
94
+ endif
95
+ ifneq ($(old_CXX) | $(old_CPPFLAGS) | $(old_CXXFLAGS) | $(old_SANITIZEFLAGS) | $(old_LDFLAGS),$(CXX) | $(CPPFLAGS) | $(CXXFLAGS) | $(SANITIZEFLAGS) | $(LDFLAGS))
96
+ .PHONY: build/test/flags
97
+ endif
98
+
99
+ # Include dependencies.
100
+ -include $(test_objs:.o=.d) $(gumbo_objs:.o=.d)
101
+ endif
@@ -0,0 +1,27 @@
1
+ Gumbo HTML parser THANKS file
2
+
3
+ Gumbo was originally written by Jonathan Tang, but many people helped out through suggestions, question-answering, code reviews, bugfixes, and organizational support. Here is a list of these people. Help me keep it complete and exempt of errors.
4
+
5
+ Adam Barth
6
+ Adam Roben
7
+ Ben Noordhuis
8
+ Bowen Han
9
+ Constantinos Michael
10
+ Craig Barnes
11
+ Geoffrey Sneddon
12
+ Ian Hickson
13
+ Jack Deng
14
+ Joel Low
15
+ Jonathan Shneier
16
+ Kevin Hendricks
17
+ Mason Tang
18
+ Maxim Zakharov
19
+ Michal Zalewski
20
+ Neal Norwitz
21
+ Othar Hansson
22
+ Ryan Grove
23
+ Stefan Haustein
24
+ Steffen Meschkat
25
+ Steven Kabbes
26
+ Thiago Farina
27
+ Vicent Marti
data/lib/nokogiri.rb CHANGED
@@ -2,38 +2,29 @@
2
2
  # frozen_string_literal: true
3
3
  # Modify the PATH on windows so that the external DLLs will get loaded.
4
4
 
5
- require 'rbconfig'
5
+ require "rbconfig"
6
6
 
7
7
  if defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
8
- require 'nokogiri/jruby/dependencies'
8
+ require_relative "nokogiri/jruby/dependencies"
9
9
  end
10
10
 
11
- require 'nokogiri/extension'
12
-
13
- require 'nokogiri/version'
14
- require 'nokogiri/syntax_error'
15
- require 'nokogiri/xml'
16
- require 'nokogiri/xslt'
17
- require 'nokogiri/html'
18
- require 'nokogiri/decorators/slop'
19
- require 'nokogiri/css'
20
- require 'nokogiri/html/builder'
11
+ require_relative "nokogiri/extension"
21
12
 
22
13
  # Nokogiri parses and searches XML/HTML very quickly, and also has
23
14
  # correctly implemented CSS3 selector support as well as XPath 1.0
24
15
  # support.
25
16
  #
26
17
  # Parsing a document returns either a Nokogiri::XML::Document, or a
27
- # Nokogiri::HTML::Document depending on the kind of document you parse.
18
+ # Nokogiri::HTML4::Document depending on the kind of document you parse.
28
19
  #
29
20
  # Here is an example:
30
21
  #
31
22
  # require 'nokogiri'
32
23
  # require 'open-uri'
33
24
  #
34
- # # Get a Nokogiri::HTML:Document for the page we’re interested in...
25
+ # # Get a Nokogiri::HTML4::Document for the page we’re interested in...
35
26
  #
36
- # doc = Nokogiri::HTML(URI.open('http://www.google.com/search?q=tenderlove'))
27
+ # doc = Nokogiri::HTML4(URI.open('http://www.google.com/search?q=tenderlove'))
37
28
  #
38
29
  # # Do funky things with it using Nokogiri::XML::Node methods...
39
30
  #
@@ -49,27 +40,27 @@ module Nokogiri
49
40
  class << self
50
41
  ###
51
42
  # Parse an HTML or XML document. +string+ contains the document.
52
- def parse string, url = nil, encoding = nil, options = nil
43
+ def parse(string, url = nil, encoding = nil, options = nil)
53
44
  if string.respond_to?(:read) ||
54
45
  /^\s*<(?:!DOCTYPE\s+)?html[\s>]/i === string[0, 512]
55
46
  # Expect an HTML indicator to appear within the first 512
56
47
  # characters of a document. (<?xml ?> + <?xml-stylesheet ?>
57
48
  # shouldn't be that long)
58
- Nokogiri.HTML(string, url, encoding,
49
+ Nokogiri.HTML4(string, url, encoding,
59
50
  options || XML::ParseOptions::DEFAULT_HTML)
60
51
  else
61
52
  Nokogiri.XML(string, url, encoding,
62
53
  options || XML::ParseOptions::DEFAULT_XML)
63
- end.tap { |doc|
54
+ end.tap do |doc|
64
55
  yield doc if block_given?
65
- }
56
+ end
66
57
  end
67
58
 
68
59
  ###
69
60
  # Create a new Nokogiri::XML::DocumentFragment
70
- def make input = nil, opts = {}, &blk
61
+ def make(input = nil, opts = {}, &blk)
71
62
  if input
72
- Nokogiri::HTML.fragment(input).children.first
63
+ Nokogiri::HTML4.fragment(input).children.first
73
64
  else
74
65
  Nokogiri(&blk)
75
66
  end
@@ -98,10 +89,10 @@ module Nokogiri
98
89
  # Make sure to support some popular encoding aliases not known by
99
90
  # all iconv implementations.
100
91
  {
101
- 'Windows-31J' => 'CP932', # Windows-31J is the IANA registered name of CP932.
102
- }.each { |alias_name, name|
92
+ "Windows-31J" => "CP932", # Windows-31J is the IANA registered name of CP932.
93
+ }.each do |alias_name, name|
103
94
  EncodingHandler.alias(name, alias_name) if EncodingHandler[alias_name].nil?
104
- }
95
+ end
105
96
  end
106
97
  end
107
98
 
@@ -109,15 +100,26 @@ module Nokogiri
109
100
  end
110
101
 
111
102
  ###
112
- # Parse a document contained in +args+. Nokogiri will try to guess what
113
- # type of document you are attempting to parse. For more information, see
114
- # Nokogiri.parse
103
+ # Parse a document contained in +args+. Nokogiri will try to guess what type of document you are
104
+ # attempting to parse. For more information, see Nokogiri.parse
115
105
  #
116
- # To specify the type of document, use Nokogiri.XML or Nokogiri.HTML.
106
+ # To specify the type of document, use {Nokogiri.XML}, {Nokogiri.HTML4}, or {Nokogiri.HTML5}.
117
107
  def Nokogiri(*args, &block)
118
108
  if block_given?
119
- Nokogiri::HTML::Builder.new(&block).doc.root
109
+ Nokogiri::HTML4::Builder.new(&block).doc.root
120
110
  else
121
111
  Nokogiri.parse(*args)
122
112
  end
123
113
  end
114
+
115
+ require_relative "nokogiri/version"
116
+ require_relative "nokogiri/syntax_error"
117
+ require_relative "nokogiri/xml"
118
+ require_relative "nokogiri/xslt"
119
+ require_relative "nokogiri/html4"
120
+ require_relative "nokogiri/html"
121
+ require_relative "nokogiri/decorators/slop"
122
+ require_relative "nokogiri/css"
123
+ require_relative "nokogiri/html4/builder"
124
+
125
+ require_relative "nokogiri/html5" if Nokogiri.uses_gumbo?