/
nokogiri@1.13.6.rbi
4935 lines (4242 loc) · 161 KB
/
nokogiri@1.13.6.rbi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# typed: true
# DO NOT EDIT MANUALLY
# This is an autogenerated file for types exported from the `nokogiri` gem.
# Please instead update this file by running `bin/tapioca gem nokogiri`.
# Nokogiri parses and searches XML/HTML very quickly, and also has
# correctly implemented CSS3 selector support as well as XPath 1.0
# support.
#
# Parsing a document returns either a Nokogiri::XML::Document, or a
# Nokogiri::HTML4::Document depending on the kind of document you parse.
#
# Here is an example:
#
# require 'nokogiri'
# require 'open-uri'
#
# # Get a Nokogiri::HTML4::Document for the page we’re interested in...
#
# doc = Nokogiri::HTML4(URI.open('http://www.google.com/search?q=tenderlove'))
#
# # Do funky things with it using Nokogiri::XML::Node methods...
#
# ####
# # Search for nodes by css
# doc.css('h3.r a.l').each do |link|
# puts link.content
# end
#
# See also:
#
# - Nokogiri::XML::Searchable#css for more information about CSS searching
# - Nokogiri::XML::Searchable#xpath for more information about XPath searching
module Nokogiri
class << self
def HTML(input, url = T.unsafe(nil), encoding = T.unsafe(nil), options = T.unsafe(nil), &block); end
# :call-seq:
# HTML4(input, url = nil, encoding = nil, options = XML::ParseOptions::DEFAULT_HTML, &block) → Nokogiri::HTML4::Document
#
# Parse HTML. Convenience method for Nokogiri::HTML4::Document.parse
def HTML4(input, url = T.unsafe(nil), encoding = T.unsafe(nil), options = T.unsafe(nil), &block); end
# Since v1.12.0
#
# ⚠ HTML5 functionality is not available when running JRuby.
#
# Parse an HTML5 document. Convenience method for {Nokogiri::HTML5::Document.parse}
def HTML5(input, url = T.unsafe(nil), encoding = T.unsafe(nil), **options, &block); end
# Parse a document and add the Slop decorator. The Slop decorator
# implements method_missing such that methods may be used instead of CSS
# or XPath. For example:
#
# doc = Nokogiri::Slop(<<-eohtml)
# <html>
# <body>
# <p>first</p>
# <p>second</p>
# </body>
# </html>
# eohtml
# assert_equal('second', doc.html.body.p[1].text)
def Slop(*args, &block); end
# Parse XML. Convenience method for Nokogiri::XML::Document.parse
def XML(thing, url = T.unsafe(nil), encoding = T.unsafe(nil), options = T.unsafe(nil), &block); end
# Create a Nokogiri::XSLT::Stylesheet with +stylesheet+.
#
# Example:
#
# xslt = Nokogiri::XSLT(File.read(ARGV[0]))
def XSLT(stylesheet, modules = T.unsafe(nil)); end
def install_default_aliases; end
# @return [Boolean]
def jruby?; end
def libxml2_patches; end
# Create a new Nokogiri::XML::DocumentFragment
def make(input = T.unsafe(nil), opts = T.unsafe(nil), &blk); end
# Parse an HTML or XML document. +string+ contains the document.
def parse(string, url = T.unsafe(nil), encoding = T.unsafe(nil), options = T.unsafe(nil)); end
# @return [Boolean]
def uses_gumbo?; end
# @return [Boolean]
def uses_libxml?(requirement = T.unsafe(nil)); end
end
end
# Translate a CSS selector into an XPath 1.0 query
module Nokogiri::CSS
class << self
# TODO: Deprecate this method ahead of 2.0 and delete it in 2.0.
# It is not used by Nokogiri and shouldn't be part of the public API.
def parse(selector); end
# :call-seq:
# xpath_for(selector) → String
# xpath_for(selector [, prefix:] [, visitor:] [, ns:]) → String
#
# Translate a CSS selector to the equivalent XPath query.
#
# [Parameters]
# - +selector+ (String) The CSS selector to be translated into XPath
#
# - +prefix:+ (String)
#
# The XPath prefix for the query, see Nokogiri::XML::XPath for some options. Default is
# +XML::XPath::GLOBAL_SEARCH_PREFIX+.
#
# - +visitor:+ (Nokogiri::CSS::XPathVisitor)
#
# The visitor class to use to transform the AST into XPath. Default is
# +Nokogiri::CSS::XPathVisitor.new+.
#
# - +ns:+ (Hash<String ⇒ String>)
#
# The namespaces that are referenced in the query, if any. This is a hash where the keys are
# the namespace prefix and the values are the namespace URIs. Default is an empty Hash.
#
# [Returns] (String) The equivalent XPath query for +selector+
#
# 💡 Note that translated queries are cached for performance concerns.
def xpath_for(selector, options = T.unsafe(nil)); end
end
end
class Nokogiri::CSS::Node
# Create a new Node with +type+ and +value+
#
# @return [Node] a new instance of Node
def initialize(type, value); end
# Accept +visitor+
def accept(visitor); end
# Find a node by type using +types+
def find_by_type(types); end
# Convert to array
def to_a; end
# Convert to_type
def to_type; end
# Convert this CSS node to xpath with +prefix+ using +visitor+
def to_xpath(prefix, visitor); end
# Get the type of this node
def type; end
# Get the type of this node
def type=(_arg0); end
# Get the value of this node
def value; end
# Get the value of this node
def value=(_arg0); end
end
Nokogiri::CSS::Node::ALLOW_COMBINATOR_ON_SELF = T.let(T.unsafe(nil), Array)
class Nokogiri::CSS::Parser < ::Racc::Parser
# Create a new CSS parser with respect to +namespaces+
#
# @return [Parser] a new instance of Parser
def initialize(namespaces = T.unsafe(nil)); end
# reduce 0 omitted
def _reduce_1(val, _values, result); end
def _reduce_10(val, _values, result); end
def _reduce_11(val, _values, result); end
# reduce 12 omitted
def _reduce_13(val, _values, result); end
def _reduce_14(val, _values, result); end
def _reduce_15(val, _values, result); end
# reduce 16 omitted
def _reduce_17(val, _values, result); end
def _reduce_18(val, _values, result); end
def _reduce_19(val, _values, result); end
def _reduce_2(val, _values, result); end
# reduce 20 omitted
def _reduce_21(val, _values, result); end
# reduce 22 omitted
def _reduce_23(val, _values, result); end
def _reduce_24(val, _values, result); end
def _reduce_25(val, _values, result); end
def _reduce_26(val, _values, result); end
# reduce 27 omitted
def _reduce_28(val, _values, result); end
def _reduce_29(val, _values, result); end
def _reduce_3(val, _values, result); end
def _reduce_30(val, _values, result); end
def _reduce_31(val, _values, result); end
def _reduce_32(val, _values, result); end
# reduce 33 omitted
def _reduce_34(val, _values, result); end
def _reduce_35(val, _values, result); end
def _reduce_36(val, _values, result); end
def _reduce_37(val, _values, result); end
def _reduce_38(val, _values, result); end
def _reduce_39(val, _values, result); end
def _reduce_4(val, _values, result); end
def _reduce_40(val, _values, result); end
def _reduce_41(val, _values, result); end
def _reduce_42(val, _values, result); end
# reduce 44 omitted
def _reduce_45(val, _values, result); end
# reduce 46 omitted
def _reduce_47(val, _values, result); end
def _reduce_48(val, _values, result); end
def _reduce_49(val, _values, result); end
def _reduce_5(val, _values, result); end
def _reduce_50(val, _values, result); end
def _reduce_51(val, _values, result); end
# reduce 53 omitted
def _reduce_54(val, _values, result); end
def _reduce_55(val, _values, result); end
def _reduce_56(val, _values, result); end
def _reduce_57(val, _values, result); end
def _reduce_58(val, _values, result); end
def _reduce_6(val, _values, result); end
# reduce 63 omitted
def _reduce_64(val, _values, result); end
def _reduce_65(val, _values, result); end
def _reduce_66(val, _values, result); end
def _reduce_67(val, _values, result); end
# reduce 68 omitted
def _reduce_69(val, _values, result); end
def _reduce_7(val, _values, result); end
def _reduce_70(val, _values, result); end
def _reduce_71(val, _values, result); end
def _reduce_72(val, _values, result); end
def _reduce_73(val, _values, result); end
def _reduce_74(val, _values, result); end
def _reduce_75(val, _values, result); end
def _reduce_76(val, _values, result); end
def _reduce_8(val, _values, result); end
def _reduce_9(val, _values, result); end
# reduce 81 omitted
def _reduce_none(val, _values, result); end
def cache_key(query, prefix, visitor); end
def next_token; end
# On CSS parser error, raise an exception
#
# @raise [SyntaxError]
def on_error(error_token_id, error_value, value_stack); end
def parse(string); end
def unescape_css_identifier(identifier); end
def unescape_css_string(str); end
# Get the xpath for +string+ using +options+
def xpath_for(string, prefix, visitor); end
class << self
# Get the css selector in +string+ from the cache
def [](string); end
# Set the css selector in +string+ in the cache to +value+
def []=(string, value); end
# Return a thread-local boolean indicating whether the CSS-to-XPath cache is active. (Default is `true`.)
#
# @return [Boolean]
def cache_on?; end
# Clear the cache
def clear_cache(create_new_object = T.unsafe(nil)); end
# Set a thread-local boolean to turn cacheing on and off. Truthy values turn the cache on, falsey values turn the cache off.
def set_cache(value); end
# Execute +block+ without cache
def without_cache(&block); end
end
end
Nokogiri::CSS::Parser::CACHE_SWITCH_NAME = T.let(T.unsafe(nil), Symbol)
Nokogiri::CSS::Parser::Racc_arg = T.let(T.unsafe(nil), Array)
Nokogiri::CSS::Parser::Racc_token_to_s_table = T.let(T.unsafe(nil), Array)
class Nokogiri::CSS::SyntaxError < ::Nokogiri::SyntaxError; end
class Nokogiri::CSS::Tokenizer
def _next_token; end
def action; end
# Returns the value of attribute filename.
def filename; end
# Returns the value of attribute lineno.
def lineno; end
def load_file(filename); end
def next_token; end
def scan(str); end
def scan_file(filename); end
def scan_setup(str); end
def scan_str(str); end
# Returns the value of attribute state.
def state; end
# Sets the attribute state
#
# @param value the value to set the attribute state to.
def state=(_arg0); end
end
class Nokogiri::CSS::Tokenizer::ScanError < ::StandardError; end
# When translating CSS selectors to XPath queries with Nokogiri::CSS.xpath_for, the XPathVisitor
# class allows for changing some of the behaviors related to builtin xpath functions and quirks
# of HTML5.
class Nokogiri::CSS::XPathVisitor
# :call-seq:
# new() → XPathVisitor
# new(builtins:, doctype:) → XPathVisitor
#
# [Parameters]
# - +builtins:+ (BuiltinsConfig) Determine when to use Nokogiri's built-in xpath functions for performance improvements.
# - +doctype:+ (DoctypeConfig) Make document-type-specific accommodations for CSS queries.
#
# [Returns] XPathVisitor
#
# @return [XPathVisitor] a new instance of XPathVisitor
def initialize(builtins: T.unsafe(nil), doctype: T.unsafe(nil)); end
def accept(node); end
# :call-seq: config() → Hash
#
# [Returns]
# a Hash representing the configuration of the XPathVisitor, suitable for use as
# part of the CSS cache key.
def config; end
def visit_attrib_name(node); end
def visit_attribute_condition(node); end
def visit_child_selector(node); end
def visit_class_condition(node); end
def visit_combinator(node); end
def visit_conditional_selector(node); end
def visit_descendant_selector(node); end
def visit_direct_adjacent_selector(node); end
def visit_element_name(node); end
def visit_following_selector(node); end
# :stopdoc:
def visit_function(node); end
def visit_id(node); end
def visit_not(node); end
def visit_pseudo_class(node); end
private
def css_class(hay, needle); end
def html5_element_name_needs_namespace_handling(node); end
# @return [Boolean]
def is_of_type_pseudo_class?(node); end
# @raise [ArgumentError]
def nth(node, options = T.unsafe(nil)); end
def read_a_and_positive_b(values); end
end
# Enum to direct XPathVisitor when to use Nokogiri builtin XPath functions.
module Nokogiri::CSS::XPathVisitor::BuiltinsConfig; end
# Always use Nokogiri builtin functions whenever possible. This is probably only useful for testing.
Nokogiri::CSS::XPathVisitor::BuiltinsConfig::ALWAYS = T.let(T.unsafe(nil), Symbol)
# Never use Nokogiri builtin functions, always generate vanilla XPath 1.0 queries. This is
# the default when calling Nokogiri::CSS.xpath_for directly.
Nokogiri::CSS::XPathVisitor::BuiltinsConfig::NEVER = T.let(T.unsafe(nil), Symbol)
# Only use Nokogiri builtin functions when they will be faster than vanilla XPath. This is
# the behavior chosen when searching for CSS selectors on a Nokogiri document, fragment, or
# node.
Nokogiri::CSS::XPathVisitor::BuiltinsConfig::OPTIMAL = T.let(T.unsafe(nil), Symbol)
Nokogiri::CSS::XPathVisitor::BuiltinsConfig::VALUES = T.let(T.unsafe(nil), Array)
# Enum to direct XPathVisitor when to tweak the XPath query to suit the nature of the document
# being searched. Note that searches for CSS selectors from a Nokogiri document, fragment, or
# node will choose the correct option automatically.
module Nokogiri::CSS::XPathVisitor::DoctypeConfig; end
# The document being searched is an HTML4 document.
Nokogiri::CSS::XPathVisitor::DoctypeConfig::HTML4 = T.let(T.unsafe(nil), Symbol)
# The document being searched is an HTML5 document.
Nokogiri::CSS::XPathVisitor::DoctypeConfig::HTML5 = T.let(T.unsafe(nil), Symbol)
Nokogiri::CSS::XPathVisitor::DoctypeConfig::VALUES = T.let(T.unsafe(nil), Array)
# The document being searched is an XML document. This is the default.
Nokogiri::CSS::XPathVisitor::DoctypeConfig::XML = T.let(T.unsafe(nil), Symbol)
Nokogiri::CSS::XPathVisitor::WILDCARD_NAMESPACES = T.let(T.unsafe(nil), TrueClass)
module Nokogiri::CSS::XPathVisitorAlwaysUseBuiltins
class << self
def new; end
end
end
module Nokogiri::CSS::XPathVisitorOptimallyUseBuiltins
class << self
def new; end
end
end
# Some classes in Nokogiri are namespaced as a group, for example
# Document, DocumentFragment, and Builder.
#
# It's sometimes necessary to look up the related class, e.g.:
#
# XML::Builder → XML::Document
# HTML4::Builder → HTML4::Document
# HTML5::Document → HTML5::DocumentFragment
#
# This module is included into those key classes who need to do this.
module Nokogiri::ClassResolver
# :call-seq:
# related_class(class_name) → Class
#
# Find a class constant within the
#
# Some examples:
#
# Nokogiri::XML::Document.new.related_class("DocumentFragment")
# # => Nokogiri::XML::DocumentFragment
# Nokogiri::HTML4::Document.new.related_class("DocumentFragment")
# # => Nokogiri::HTML4::DocumentFragment
#
# Note this will also work for subclasses that follow the same convention, e.g.:
#
# Loofah::HTML::Document.new.related_class("DocumentFragment")
# # => Loofah::HTML::DocumentFragment
#
# And even if it's a subclass, this will iterate through the superclasses:
#
# class ThisIsATopLevelClass < Nokogiri::HTML4::Builder ; end
# ThisIsATopLevelClass.new.related_class("Document")
# # => Nokogiri::HTML4::Document
def related_class(class_name); end
end
# #related_class restricts matching namespaces to those matching this set.
Nokogiri::ClassResolver::VALID_NAMESPACES = T.let(T.unsafe(nil), Set)
module Nokogiri::Decorators; end
# The Slop decorator implements method missing such that a methods may be
# used instead of XPath or CSS. See Nokogiri.Slop
module Nokogiri::Decorators::Slop
# look for node with +name+. See Nokogiri.Slop
def method_missing(name, *args, &block); end
private
# @return [Boolean]
def respond_to_missing?(name, include_private = T.unsafe(nil)); end
end
# The default XPath search context for Slop
Nokogiri::Decorators::Slop::XPATH_PREFIX = T.let(T.unsafe(nil), String)
class Nokogiri::EncodingHandler
def name; end
class << self
def [](_arg0); end
def alias(_arg0, _arg1); end
def clear_aliases!; end
def delete(_arg0); end
end
end
module Nokogiri::Gumbo
class << self
def fragment(_arg0, _arg1, _arg2, _arg3, _arg4, _arg5); end
def parse(_arg0, _arg1, _arg2, _arg3, _arg4); end
end
end
# The default maximum number of attributes per element.
Nokogiri::Gumbo::DEFAULT_MAX_ATTRIBUTES = T.let(T.unsafe(nil), Integer)
# The default maximum number of errors for parsing a document or a fragment.
Nokogiri::Gumbo::DEFAULT_MAX_ERRORS = T.let(T.unsafe(nil), Integer)
# The default maximum depth of the DOM tree produced by parsing a document
# or fragment.
Nokogiri::Gumbo::DEFAULT_MAX_TREE_DEPTH = T.let(T.unsafe(nil), Integer)
# 💡 This module/namespace is an alias for Nokogiri::HTML4 as of v1.12.0. Before v1.12.0,
# Nokogiri::HTML4 did not exist, and this was the module/namespace for all HTML-related
# classes.
Nokogiri::HTML = Nokogiri::HTML4
# Since v1.12.0
#
# 💡 Before v1.12.0, Nokogiri::HTML4 did not exist, and Nokogiri::HTML was the module/namespace
# for parsing HTML.
module Nokogiri::HTML4
class << self
# Parse a fragment from +string+ in to a NodeSet.
def fragment(string, encoding = T.unsafe(nil), options = T.unsafe(nil), &block); end
# Parse HTML. Convenience method for Nokogiri::HTML4::Document.parse
def parse(input, url = T.unsafe(nil), encoding = T.unsafe(nil), options = T.unsafe(nil), &block); end
end
end
# Nokogiri HTML builder is used for building HTML documents. It is very
# similar to the Nokogiri::XML::Builder. In fact, you should go read the
# documentation for Nokogiri::XML::Builder before reading this
# documentation.
#
# == Synopsis:
#
# Create an HTML document with a body that has an onload attribute, and a
# span tag with a class of "bold" that has content of "Hello world".
#
# builder = Nokogiri::HTML4::Builder.new do |doc|
# doc.html {
# doc.body(:onload => 'some_func();') {
# doc.span.bold {
# doc.text "Hello world"
# }
# }
# }
# end
# puts builder.to_html
#
# The HTML builder inherits from the XML builder, so make sure to read the
# Nokogiri::XML::Builder documentation.
class Nokogiri::HTML4::Builder < ::Nokogiri::XML::Builder
# Convert the builder to HTML
def to_html; end
end
class Nokogiri::HTML4::Document < ::Nokogiri::XML::Document
# Create a Nokogiri::XML::DocumentFragment from +tags+
def fragment(tags = T.unsafe(nil)); end
# Get the meta tag encoding for this document. If there is no meta tag,
# then nil is returned.
def meta_encoding; end
# Set the meta tag encoding for this document.
#
# If an meta encoding tag is already present, its content is
# replaced with the given text.
#
# Otherwise, this method tries to create one at an appropriate
# place supplying head and/or html elements as necessary, which
# is inside a head element if any, and before any text node or
# content element (typically <body>) if any.
#
# The result when trying to set an encoding that is different
# from the document encoding is undefined.
#
# Beware in CRuby, that libxml2 automatically inserts a meta tag
# into a head element.
def meta_encoding=(encoding); end
# Serialize Node using +options+. Save options can also be set using a block.
#
# See also Nokogiri::XML::Node::SaveOptions and Node@Serialization+and+Generating+Output.
#
# These two statements are equivalent:
#
# node.serialize(:encoding => 'UTF-8', :save_with => FORMAT | AS_XML)
#
# or
#
# node.serialize(:encoding => 'UTF-8') do |config|
# config.format.as_xml
# end
def serialize(options = T.unsafe(nil)); end
# Get the title string of this document. Return nil if there is
# no title tag.
def title; end
# Set the title string of this document.
#
# If a title element is already present, its content is replaced
# with the given text.
#
# Otherwise, this method tries to create one at an appropriate
# place supplying head and/or html elements as necessary, which
# is inside a head element if any, right after a meta
# encoding/charset tag if any, and before any text node or
# content element (typically <body>) if any.
def title=(text); end
def type; end
# :call-seq:
# xpath_doctype() → Nokogiri::CSS::XPathVisitor::DoctypeConfig
#
# [Returns] The document type which determines CSS-to-XPath translation.
#
# See XPathVisitor for more information.
def xpath_doctype; end
private
def meta_content_type; end
def set_metadata_element(element); end
class << self
def new(*_arg0); end
# Parse HTML. +string_or_io+ may be a String, or any object that
# responds to _read_ and _close_ such as an IO, or StringIO.
# +url+ is resource where this document is located. +encoding+ is the
# encoding that should be used when processing the document. +options+
# is a number that sets options in the parser, such as
# Nokogiri::XML::ParseOptions::RECOVER. See the constants in
# Nokogiri::XML::ParseOptions.
#
# @yield [options]
def parse(string_or_io, url = T.unsafe(nil), encoding = T.unsafe(nil), options = T.unsafe(nil)); end
def read_io(_arg0, _arg1, _arg2, _arg3); end
def read_memory(_arg0, _arg1, _arg2, _arg3); end
end
end
class Nokogiri::HTML4::Document::EncodingFound < ::StandardError
# @return [EncodingFound] a new instance of EncodingFound
def initialize(encoding); end
# Returns the value of attribute found_encoding.
def found_encoding; end
end
class Nokogiri::HTML4::Document::EncodingReader
# @return [EncodingReader] a new instance of EncodingReader
def initialize(io); end
# This method is used by the C extension so that
# Nokogiri::HTML4::Document#read_io() does not leak memory when
# EncodingFound is raised.
def encoding_found; end
def read(len); end
class << self
def detect_encoding(chunk); end
end
end
class Nokogiri::HTML4::Document::EncodingReader::JumpSAXHandler < ::Nokogiri::HTML4::Document::EncodingReader::SAXHandler
# @return [JumpSAXHandler] a new instance of JumpSAXHandler
def initialize(jumptag); end
def start_element(name, attrs = T.unsafe(nil)); end
end
class Nokogiri::HTML4::Document::EncodingReader::SAXHandler < ::Nokogiri::XML::SAX::Document
# @return [SAXHandler] a new instance of SAXHandler
def initialize; end
# Returns the value of attribute encoding.
def encoding; end
def start_element(name, attrs = T.unsafe(nil)); end
end
class Nokogiri::HTML4::DocumentFragment < ::Nokogiri::XML::DocumentFragment
# @return [DocumentFragment] a new instance of DocumentFragment
# @yield [options]
def initialize(document, tags = T.unsafe(nil), ctx = T.unsafe(nil), options = T.unsafe(nil)); end
class << self
# Create a Nokogiri::XML::DocumentFragment from +tags+, using +encoding+
def parse(tags, encoding = T.unsafe(nil), options = T.unsafe(nil), &block); end
end
end
class Nokogiri::HTML4::ElementDescription
# Is this element a block element?
#
# @return [Boolean]
def block?; end
def default_sub_element; end
# @return [Boolean]
def deprecated?; end
def deprecated_attributes; end
def description; end
def empty?; end
# @return [Boolean]
def implied_end_tag?; end
# @return [Boolean]
def implied_start_tag?; end
def inline?; end
# Inspection information
def inspect; end
def name; end
def optional_attributes; end
def required_attributes; end
# @return [Boolean]
def save_end_tag?; end
def sub_elements; end
# Convert this description to a string
def to_s; end
private
def default_desc; end
class << self
def [](_arg0); end
end
end
Nokogiri::HTML4::ElementDescription::ACTION_ATTR = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::ALIGN_ATTR = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::ALT_ATTR = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::APPLET_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::AREA_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::A_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::BASEFONT_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::BGCOLOR_ATTR = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::BLOCK = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::BLOCKLI_ELT = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::BODY_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::BODY_CONTENTS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::BODY_DEPR = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::BUTTON_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::CELLHALIGN = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::CELLVALIGN = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::CLEAR_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::COL_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::COL_ELT = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::COMPACT_ATTR = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::COMPACT_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::CONTENT_ATTR = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::COREATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::CORE_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::CORE_I18N_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::DIR_ATTR = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::DL_CONTENTS = T.let(T.unsafe(nil), Array)
# This is filled in down below.
Nokogiri::HTML4::ElementDescription::DefaultDescriptions = T.let(T.unsafe(nil), Hash)
# Methods are defined protected by method_defined? because at
# this point the C-library or Java library is already loaded,
# and we don't want to clobber any methods that have been
# defined there.
Nokogiri::HTML4::ElementDescription::Desc = Struct
Nokogiri::HTML4::ElementDescription::EDIT_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::EMBED_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::EMPTY = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::EVENTS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::FIELDSET_CONTENTS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::FLOW = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::FLOW_PARAM = T.let(T.unsafe(nil), Array)
# Attributes defined and categorized
Nokogiri::HTML4::ElementDescription::FONTSTYLE = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::FONT_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::FORMCTRL = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::FORM_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::FORM_CONTENTS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::FRAMESET_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::FRAMESET_CONTENTS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::FRAME_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::HEADING = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::HEAD_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::HEAD_CONTENTS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::HREF_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::HR_DEPR = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::HTML_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::HTML_CDATA = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::HTML_CONTENT = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::HTML_FLOW = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::HTML_INLINE = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::HTML_PCDATA = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::I18N = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::I18N_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::IFRAME_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::IMG_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::INLINE = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::INLINE_P = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::INPUT_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::LABEL_ATTR = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::LABEL_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::LANGUAGE_ATTR = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::LEGEND_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::LINK_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::LIST = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::LI_ELT = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::MAP_CONTENTS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::META_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::MODIFIER = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::NAME_ATTR = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::NOFRAMES_CONTENT = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::OBJECT_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::OBJECT_CONTENTS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::OBJECT_DEPR = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::OL_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::OPTGROUP_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::OPTION_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::OPTION_ELT = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::PARAM_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::PCDATA = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::PHRASE = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::PRE_CONTENT = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::PROMPT_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::QUOTE_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::ROWS_COLS_ATTR = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::SCRIPT_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::SELECT_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::SELECT_CONTENT = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::SPECIAL = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::SRC_ALT_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::STYLE_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::TABLE_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::TABLE_CONTENTS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::TABLE_DEPR = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::TALIGN_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::TARGET_ATTR = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::TEXTAREA_ATTRS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::TH_TD_ATTR = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::TH_TD_DEPR = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::TR_CONTENTS = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::TR_ELT = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::TYPE_ATTR = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::UL_DEPR = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::VERSION_ATTR = T.let(T.unsafe(nil), Array)
Nokogiri::HTML4::ElementDescription::WIDTH_ATTR = T.let(T.unsafe(nil), Array)
class Nokogiri::HTML4::EntityDescription < ::Struct; end
class Nokogiri::HTML4::EntityLookup
# Look up entity with +name+
def [](name); end
def get(_arg0); end
end
# Instance of Nokogiri::HTML4::EntityLookup
Nokogiri::HTML4::NamedCharacters = T.let(T.unsafe(nil), Nokogiri::HTML4::EntityLookup)
# Nokogiri lets you write a SAX parser to process HTML but get HTML correction features.
#
# See Nokogiri::HTML4::SAX::Parser for a basic example of using a SAX parser with HTML.
#
# For more information on SAX parsers, see Nokogiri::XML::SAX
module Nokogiri::HTML4::SAX; end
# This class lets you perform SAX style parsing on HTML with HTML error correction.
#
# Here is a basic usage example:
#
# class MyDoc < Nokogiri::XML::SAX::Document
# def start_element name, attributes = []
# puts "found a #{name}"
# end
# end
#
# parser = Nokogiri::HTML4::SAX::Parser.new(MyDoc.new)
# parser.parse(File.read(ARGV[0], mode: 'rb'))
#
# For more information on SAX parsers, see Nokogiri::XML::SAX
class Nokogiri::HTML4::SAX::Parser < ::Nokogiri::XML::SAX::Parser
# Parse a file with +filename+
#
# @raise [ArgumentError]
# @yield [ctx]
def parse_file(filename, encoding = T.unsafe(nil)); end
# Parse given +io+
#
# @yield [ctx]
def parse_io(io, encoding = T.unsafe(nil)); end
# Parse html stored in +data+ using +encoding+
#
# @raise [TypeError]
# @yield [ctx]
def parse_memory(data, encoding = T.unsafe(nil)); end
end
# Context for HTML SAX parsers. This class is usually not instantiated by the user. Instead,
# you should be looking at Nokogiri::HTML4::SAX::Parser
class Nokogiri::HTML4::SAX::ParserContext < ::Nokogiri::XML::SAX::ParserContext
def parse_with(_arg0); end
class << self
def file(_arg0, _arg1); end
def memory(_arg0, _arg1); end
def new(thing, encoding = T.unsafe(nil)); end
end
end
class Nokogiri::HTML4::SAX::PushParser < ::Nokogiri::XML::SAX::PushParser
# @return [PushParser] a new instance of PushParser
def initialize(doc = T.unsafe(nil), file_name = T.unsafe(nil), encoding = T.unsafe(nil)); end
# Write a +chunk+ of HTML to the PushParser. Any callback methods
# that can be called will be called immediately.
def <<(chunk, last_chunk = T.unsafe(nil)); end
# The Nokogiri::HTML4::SAX::Document on which the PushParser will be
# operating
def document; end
# The Nokogiri::HTML4::SAX::Document on which the PushParser will be
# operating
def document=(_arg0); end
# Finish the parsing. This method is only necessary for
# Nokogiri::HTML4::SAX::Document#end_document to be called.
def finish; end
# Write a +chunk+ of HTML to the PushParser. Any callback methods
# that can be called will be called immediately.
def write(chunk, last_chunk = T.unsafe(nil)); end
private
def initialize_native(_arg0, _arg1, _arg2); end
def native_write(_arg0, _arg1); end
end
# == Usage
#
# ⚠ HTML5 functionality is not available when running JRuby.
#
# Parse an HTML5 document:
#
# doc = Nokogiri.HTML5(string)
#
# Parse an HTML5 fragment:
#
# fragment = Nokogiri::HTML5.fragment(string)
#
# == Parsing options
#
# The document and fragment parsing methods support options that are different from Nokogiri's.
#
# - <tt>Nokogiri.HTML5(html, url = nil, encoding = nil, options = {})</tt>