huskies: merge 927

This commit is contained in:
dave
2026-05-12 17:55:12 +00:00
parent b8945654bf
commit 03a99b3cf1
33 changed files with 119 additions and 25 deletions
+3 -2
View File
@@ -1,4 +1,5 @@
//! WhatsApp message formatting — Markdown-to-WhatsApp conversion and message chunking.
use crate::chat::util::truncate_at_char_boundary;
use regex::Regex;
use std::sync::LazyLock;
@@ -24,13 +25,13 @@ pub fn chunk_for_whatsapp(text: &str) -> Vec<String> {
}
// Find the best split point within the limit.
let window = &remaining[..WHATSAPP_MAX_MESSAGE_LEN];
let window = truncate_at_char_boundary(remaining, WHATSAPP_MAX_MESSAGE_LEN);
// Prefer paragraph boundary.
let split_pos = window
.rfind("\n\n")
.or_else(|| window.rfind('\n'))
.unwrap_or(WHATSAPP_MAX_MESSAGE_LEN);
.unwrap_or(window.len());
let (chunk, rest) = remaining.split_at(split_pos);
let chunk = chunk.trim();