Skip to content

Commit

Permalink
Bump html2text to v0.13
Browse files Browse the repository at this point in the history
  • Loading branch information
deedy5 committed Oct 15, 2024
1 parent 35e9eff commit c460078
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
19 changes: 10 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ encoding_rs = { version = "0.8" }
ahash = "0.8"
indexmap = { version = "2", features = ["serde"] }
tokio = { version = "1", features = ["full"] }
html2text = "0.12"
html2text = "0.13"
bytes = "1"

[profile.release]
Expand Down
8 changes: 4 additions & 4 deletions src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use anyhow::{anyhow, Result};
use encoding_rs::Encoding;
use html2text::{
from_read, from_read_with_decorator,
render::text_renderer::{RichDecorator, TrivialDecorator},
render::{RichDecorator, TrivialDecorator},
};
use indexmap::IndexMap;
use pyo3::{prelude::*, types::PyBytes};
Expand Down Expand Up @@ -85,23 +85,23 @@ impl Response {
#[getter]
fn text_markdown(&mut self, py: Python) -> Result<String> {
let raw_bytes = self.content.bind(py).as_bytes();
let text = py.allow_threads(|| from_read(raw_bytes, 100));
let text = py.allow_threads(|| from_read(raw_bytes, 100))?;
Ok(text)
}

#[getter]
fn text_plain(&mut self, py: Python) -> Result<String> {
let raw_bytes = self.content.bind(py).as_bytes();
let text =
py.allow_threads(|| from_read_with_decorator(raw_bytes, 100, TrivialDecorator::new()));
py.allow_threads(|| from_read_with_decorator(raw_bytes, 100, TrivialDecorator::new()))?;
Ok(text)
}

#[getter]
fn text_rich(&mut self, py: Python) -> Result<String> {
let raw_bytes = self.content.bind(py).as_bytes();
let text =
py.allow_threads(|| from_read_with_decorator(raw_bytes, 100, RichDecorator::new()));
py.allow_threads(|| from_read_with_decorator(raw_bytes, 100, RichDecorator::new()))?;
Ok(text)
}
}

0 comments on commit c460078

Please sign in to comment.