From: Simon Tatham Date: Fri, 5 Jan 2024 12:57:43 +0000 (+0000) Subject: Split media URLs at w-1 chars, not w. X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=c312ae6fe782f20fbe58ddd23a3d6e672f475fe1;p=mastodonochrome.git Split media URLs at w-1 chars, not w. This makes no real difference, but now they match the URLs in the text of posts. In the Python version both split at w, but now that I'm delegating HTML processing to html2text, that splits overlong words at the same width it wraps sensible lines to. So I have to either have them inconsistent or change the media one. w-1 is more 'Mono' anyway, let's be honest :-) --- diff --git a/src/text.rs b/src/text.rs index fde9cdc..0337d3d 100644 --- a/src/text.rs +++ b/src/text.rs @@ -1252,7 +1252,8 @@ impl TextFragment for Media { fn render_highlighted(&self, width: usize, _highlight: Option) -> Vec { - let mut lines = vec! { ColouredString::uniform(&self.url, 'M') }; + let mut lines: Vec<_> = ColouredString::uniform(&self.url, 'M') + .split(width.saturating_sub(1)).map(|x| x.to_owned()).collect(); for para in &self.description { lines.extend_from_slice(¶.render(width)); }