Skip to content

Commit 7b70515

Browse files
infewsflavorjones
authored andcommitted
Adds support for keyword arguments for Nokogiri::HTML4::SAX::PushParser
1 parent 141d3bc commit 7b70515

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/nokogiri/html4/sax/push_parser.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class PushParser
88
# operating
99
attr_accessor :document
1010

11-
def initialize(doc = HTML4::SAX::Document.new, file_name = nil, encoding = "UTF-8")
11+
def initialize(doc = HTML4::SAX::Document.new, file_name_ = nil, encoding_ = "UTF-8", file_name: file_name_, encoding: encoding_)
1212
@document = doc
1313
@encoding = encoding
1414
@sax_parser = HTML4::SAX::Parser.new(doc, @encoding)

test/html4/sax/test_push_parser.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,17 @@
6666
it :test_default_options do
6767
assert_equal(0, parser.options)
6868
end
69+
70+
it :test_keyword_arguments do
71+
parser = Nokogiri::HTML4::SAX::PushParser.new(Nokogiri::SAX::TestCase::Doc.new, encoding: "UTF-8")
72+
73+
parser << (<<~HTML)
74+
<p id="asdfasdf">
75+
<!-- This is a comment -->
76+
Paragraph 1
77+
</p>
78+
HTML
79+
parser.finish
80+
assert_equal([" This is a comment "], parser.document.comments)
81+
end
6982
end

0 commit comments

Comments
 (0)