Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -776,9 +776,8 @@ pub enum LogLevel {
}

impl Readability {
/// Create a new Readability parser from HTML content
pub fn new(html: &str, options: Option<ReadabilityOptions>) -> Result<Self, ReadabilityError> {
let document = Html::parse_document(html);
/// Create a new Readability parser from a parsed HTML document
pub fn new_from_document(document: Html, options: Option<ReadabilityOptions>) -> Result<Self, ReadabilityError> {
let options = options.unwrap_or_default();

Ok(Self {
Expand All @@ -800,6 +799,12 @@ impl Readability {
})
}

/// Create a new Readability parser from HTML content
pub fn new(html: &str, options: Option<ReadabilityOptions>) -> Result<Self, ReadabilityError> {
let document = Html::parse_document(html);
Self::new_from_document(document, options)
}

/// Create a new Readability parser with a base URI for resolving relative URLs
pub fn new_with_base_uri(html: &str, base_uri: &str, options: Option<ReadabilityOptions>) -> Result<Self, ReadabilityError> {
let mut parser = Self::new(html, options)?;
Expand Down