jhy / jsoup

jsoup: the Java HTML parser, built for HTML editing, cleaning, scraping, and XSS safety.
https://jsoup.org
MIT License
10.94k stars 2.19k forks source link

Expand support for java.io.Reader #1177

Open benmccann opened 5 years ago

benmccann commented 5 years ago

I see that in https://github.com/jhy/jsoup/issues/463 some support for Reader was added: https://jsoup.org/apidocs/org/jsoup/parser/Parser.html#parseInput-java.io.Reader-java.lang.String-

However, I'm not quite sure how to use it. It looks like none of the Jsoup.parse methods take a reader. Would it be possible to add a new method taking a Reader? I'm trying to use Jsoup inside an interface that only has a Reader available

HansBrende commented 5 years ago

Just use Parser.htmlParser().parseInput(reader, baseUri).

HansBrende commented 5 years ago

You're right though that the functionality to parse a document fragment from a reader is missing. That's an open issue I raised some time ago here: #1143.

benmccann commented 5 years ago

Thanks. It might be helpful to document Parser if that's the intended method. None of the examples refer to it, so it took me awhile to discover

I've sent https://github.com/jhy/jsoup/pull/1178, which adds it to the Jsoup class, which seemed to be the intended entry point for all calls from the docs