From 7b7051552a36128e7b62746674a380d382993eec Mon Sep 17 00:00:00 2001 From: "Davis W. Frank" Date: Thu, 14 Nov 2024 12:13:32 -0600 Subject: [PATCH] Adds support for keyword arguments for Nokogiri::HTML4::SAX::PushParser --- lib/nokogiri/html4/sax/push_parser.rb | 2 +- test/html4/sax/test_push_parser.rb | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/nokogiri/html4/sax/push_parser.rb b/lib/nokogiri/html4/sax/push_parser.rb index d77b785ac1..0c9f4dda0f 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 6eb83c8339..03c44149bd 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