From: Simon Tatham Date: Mon, 25 Dec 2023 15:56:08 +0000 (+0000) Subject: push_para X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=8f3d38086de84c4bbd5c6f840fa1eaffaf11b7d2;p=mastodonochrome.git push_para --- diff --git a/src/text.rs b/src/text.rs index 20e7399..6cbcf3e 100644 --- a/src/text.rs +++ b/src/text.rs @@ -240,6 +240,20 @@ impl Paragraph { self } + pub fn push_para(mut self, para: &Paragraph) -> Self { + let tail = if let Some(last_existing_word) = self.words.last_mut() { + if let Some(first_new_word) = para.words.first() { + if last_existing_word.is_space() == + first_new_word.is_space() { + last_existing_word.push_str(&first_new_word.slice()); + 1 + } else { 0 } + } else { 0 } + } else { 0 }; + self.words.extend_from_slice(¶.words[tail..]); + self + } + pub fn into_box(self) -> Box { Box::new(self) } } @@ -474,3 +488,12 @@ fn test_fileheader() { }); } +// TODO: +// ExtendableIndicator at file header (with an 'active' flag) +// InReplyToLine, with first line of included paragraph +// NotificationLog, also with included toot +// UserListEntry +// Media +// FileStatusLine, with priorities +// MenuKeypressLine +// And, of course, the HTML parsing