diff --git a/lib/nokogiri/html4/sax/push_parser.rb b/lib/nokogiri/html4/sax/push_parser.rb index d77b785ac1c..0c9f4dda0f0 100644 --- a/lib/nokogiri/html4/sax/push_parser.rb +++ b/lib/nokogiri/html4/sax/push_parser.rb @@ -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) diff --git a/test/html4/sax/test_push_parser.rb b/test/html4/sax/test_push_parser.rb index 6eb83c8339b..eb726e15e73 100644 --- a/test/html4/sax/test_push_parser.rb +++ b/test/html4/sax/test_push_parser.rb @@ -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) +

+ + Paragraph 1 +

+ HTML + parser.finish + assert_equal([" This is a comment "], parser.document.comments) + end end