diff --git a/CHANGELOG.md b/CHANGELOG.md index 99a8fc6091e..0657ecc44ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -73,6 +73,7 @@ We've resolved many long-standing bugs in the various schema classes, validation * CSS queries for pseudo-selectors that cannot be translated into XPath expressions now raise a more descriptive `Nokogiri::CSS::SyntaxError` when they are parsed. Previously, an invalid XPath expression was evaluated and a hard-to-understand XPath error was raised by the query engine. [#3193] @flavorjones * `Schema#validate` returns errors on empty and malformed files. Previously, it would return errors on empty/malformed Documents, but not when reading from files. [#642] @flavorjones * `XML::Builder` is now consistent with how it sets block scope. Previously, missing methods with blocks on dynamically-created nodes were always handled by invoking `instance_eval(&block)` on the Builder, even when the Builder was yielding self for all other missing methods with blocks. [#1041] @flavorjones +* `HTML4::DocumentFragment.parse` accepts `IO` input. Previously, it required a string and would raise a `TypeError` when passed an `IO`. [#2069] @sharvy * [CRuby] libgumbo (the HTML5 parser) treats reaching max-depth as EOF. This addresses a class of issues when the parser is interrupted in this way. [#3121] @stevecheckoway * [CRuby] Update node GC lifecycle to avoid a potential memory leak with fragments in libxml 2.13.0 caused by changes in `xmlAddChild`. [#3156] @flavorjones * [CRuby] libgumbo correctly prints nonstandard element names in error messages. [#3219] @stevecheckoway diff --git a/lib/nokogiri/html4/document_fragment.rb b/lib/nokogiri/html4/document_fragment.rb index af97dcb704b..1681822acbb 100644 --- a/lib/nokogiri/html4/document_fragment.rb +++ b/lib/nokogiri/html4/document_fragment.rb @@ -3,11 +3,72 @@ module Nokogiri module HTML4 class DocumentFragment < Nokogiri::XML::DocumentFragment - #### - # Create a Nokogiri::XML::DocumentFragment from +tags+, using +encoding+ + # + # :call-seq: + # parse(tags) => DocumentFragment + # parse(tags, encoding) => DocumentFragment + # parse(tags, encoding, options) => DocumentFragment + # parse(tags, encoding) { |options| ... } => DocumentFragment + # + # Parse an HTML4 fragment. + # + # [Parameters] + # - +tags+ (optional String, or any object that responds to +#read+ such as an IO, or + # StringIO) + # - +encoding+ (optional String) the name of the encoding that should be used when processing + # the document. (default +nil+ for auto-detection) + # - +options+ (optional) configuration object that sets options during parsing, such as + # Nokogiri::XML::ParseOptions::RECOVER. See Nokogiri::XML::ParseOptions for more + # information. + # + # [Yields] If present, the block will be passed a Nokogiri::XML::ParseOptions object to modify + # before the fragment is parsed. See Nokogiri::XML::ParseOptions for more information. + # + # [Returns] DocumentFragment + # + # *Example:* Parsing a string + # + # fragment = DocumentFragment.parse("