huskies: merge 927
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user