storkit: merge 427_story_server_side_text_normalization_for_chat_message_line_breaks

This commit is contained in:
dave
2026-03-28 10:39:13 +00:00
parent 1ae2fa9b9b
commit 52513b55ff
4 changed files with 196 additions and 1 deletions
@@ -55,6 +55,9 @@ pub fn chunk_for_whatsapp(text: &str) -> Vec<String> {
/// This function converts common Markdown constructs so messages render
/// nicely in WhatsApp instead of showing raw Markdown syntax.
pub fn markdown_to_whatsapp(text: &str) -> String {
let normalized = crate::chat::util::normalize_line_breaks(text);
let text = normalized.as_str();
// Regexes are compiled once and reused across calls.
static RE_FENCED_BLOCK: LazyLock<Regex> =
LazyLock::new(|| Regex::new(r"(?ms)^```.*?\n(.*?)^```").unwrap());