Describe the bug
HTML4::Document.parse, HTML5::Document.parse, and HTML5::DocumentFragment.parse all accept IO objects.
But HTML4::DocumentFragment.parse raises an unobvious exception when we do this.
To Reproduce
#! /usr/bin/env ruby
puts Nokogiri::HTML4::DocumentFragment.parse(StringIO.new("<div>hello</div>"))
emits:
/home/flavorjones/code/oss/nokogiri/lib/nokogiri/html4/document_fragment.rb:40:in `match?': no implicit conversion of StringIO into String (TypeError)
path = if /^\s*?<body/i.match?(tags)
^^^^
from /home/flavorjones/code/oss/nokogiri/lib/nokogiri/html4/document_fragment.rb:40:in `initialize'
from /home/flavorjones/code/oss/nokogiri/lib/nokogiri/html4/document_fragment.rb:24:in `new'
from /home/flavorjones/code/oss/nokogiri/lib/nokogiri/html4/document_fragment.rb:24:in `parse'
from (irb):5:in `<main>'
Expected behavior
I'd like the HTML4::DocumentFragment.parse method(s) be able to handle an IO object, even if that means we just #read the whole string into a String.
Describe the bug
HTML4::Document.parse,HTML5::Document.parse, andHTML5::DocumentFragment.parseall accept IO objects.But
HTML4::DocumentFragment.parseraises an unobvious exception when we do this.To Reproduce
emits:
Expected behavior
I'd like the
HTML4::DocumentFragment.parsemethod(s) be able to handle an IO object, even if that means we just#readthe whole string into aString.