Skip to content
Snippets Groups Projects
Commit 543e76ed authored by Simon Tatham's avatar Simon Tatham
Browse files

Update to html2text 0.13.2.

This brings a new feature: we can set 'white-space: pre-wrap' as a CSS
attribute, preserving details of whitespace (multiple spaces, spaces
at start of paragraph) while still wrapping words. The web Mastodon
client sets this by default on <p> elements, and I think we should
too, because it means indented displays such as code snippets are
displayed properly.

(Particularly important in Python, where the whitespace is semantic!
E.g. https://mastodon.social/@glyph/112628092787725236 rendered
illegibly before this change, and now you can see what the code is
supposed to be doing.)

0.13.x also includes an API change making the text_renderer module
private. But that's OK, we can still import all the things we needed
from the parent module. The net effect is to save us 15 characters :-)
parent 63ad334d
No related branches found
No related tags found
1 merge request!33Another rewrite of the File screen layout code.
Pipeline #749324 passed with stages
in 11 minutes and 23 seconds
This diff is collapsed.
......@@ -14,7 +14,7 @@ clap = { version = "4.4.12", features = ["derive"] }
crossterm = "0.27.0"
derive_more = "0.99.17"
email_address = "0.2.4"
html2text = { version = "0.12.5", features = ["css"] }
html2text = { version = "0.13.2", features = ["css"] }
itertools = "0.12.0"
lazy_static = "1.4.0"
mastodonochrome_macros = { path = "macros", version = "0.1.1" }
......
use html2text::render::text_renderer::{
TaggedLine, TaggedLineElement, TextDecorator,
};
use html2text::render::{TaggedLine, TaggedLineElement, TextDecorator};
pub use html2text::RenderTree;
use html2text::{config, Colour};
use std::cell::RefCell;
......@@ -184,6 +182,7 @@ pub fn parse(html: &str) -> Result<RenderTree, html2text::Error> {
r##"
.mention { color: #010203; }
.hashtag { color: #040506; }
p { white-space: pre-wrap; }
"##,
)?;
let dom = cfg.parse_html(html.as_bytes())?;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment