Skip to content

Commit

Permalink
Adds support for keyword arguments for Nokogiri::HTML4::SAX::PushParser
Browse files Browse the repository at this point in the history
  • Loading branch information
infews authored and flavorjones committed Nov 14, 2024
1 parent 141d3bc commit 7b70515
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/nokogiri/html4/sax/push_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class PushParser
# operating
attr_accessor :document

def initialize(doc = HTML4::SAX::Document.new, file_name = nil, encoding = "UTF-8")
def initialize(doc = HTML4::SAX::Document.new, file_name_ = nil, encoding_ = "UTF-8", file_name: file_name_, encoding: encoding_)
@document = doc
@encoding = encoding
@sax_parser = HTML4::SAX::Parser.new(doc, @encoding)
Expand Down
13 changes: 13 additions & 0 deletions test/html4/sax/test_push_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,17 @@
it :test_default_options do
assert_equal(0, parser.options)
end

it :test_keyword_arguments do
parser = Nokogiri::HTML4::SAX::PushParser.new(Nokogiri::SAX::TestCase::Doc.new, encoding: "UTF-8")

parser << (<<~HTML)
<p id="asdfasdf">
<!-- This is a comment -->
Paragraph 1
</p>
HTML
parser.finish
assert_equal([" This is a comment "], parser.document.comments)
end
end

0 comments on commit 7b70515

Please sign in to comment.