diff --git a/src/main.rs b/src/main.rs index 4d4563f..74b28ea 100644 --- a/src/main.rs +++ b/src/main.rs @@ -72,7 +72,14 @@ fn create_html_card(entry: &Entry) -> Markup { fn truncate_description(description: &str, max_length: usize) -> String { let description_trimmed = description.trim(); if description_trimmed.len() > max_length { - format!("{}...", &description_trimmed[..max_length]) + let mut char_boundary = max_length; + for (idx, _) in description_trimmed.char_indices() { + if idx > max_length { + break; + } + char_boundary = idx; + } + format!("{}...", &description_trimmed[..char_boundary]) } else { description_trimmed.to_string() }