commit 943a259fd1c1fc9731a3ebc7124fb1c0bb742882 (HEAD -> main, thyestes/main) Author: Simon Tatham Date: Sat Oct 12 10:56:11 2024 +0100 Update to html2text 0.13.0. 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

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.0 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 :-) diff --git a/src/html.rs b/src/html.rs index 3b7f78f..298d6d7 100644 --- a/src/html.rs +++ b/src/html.rs @@ -1,4 +1,4 @@ -use html2text::render::text_renderer::{ +use html2text::render::{ TaggedLine, TaggedLineElement, TextDecorator, }; pub use html2text::RenderTree; @@ -184,6 +184,7 @@ pub fn parse(html: &str) -> Result { r##" .mention { color: #010203; } .hashtag { color: #040506; } +p { white-space: pre-wrap; } "##, )?; let dom = cfg.parse_html(html.as_bytes())?;