From 42c84826603bc1eff8f6082ad3349a9d5b690caf Mon Sep 17 00:00:00 2001 From: Adam Israel Date: Sat, 8 Aug 2026 11:13:52 -0400 Subject: [PATCH 1/2] fix(smartquotes): Convert Smart Quotes to straight quotes Importing stories has left some with a mix of smart and straight quotes. For our purposes, we always want to use straight quotes, so this fix will replace any found smart quotes. --- src/markdown.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/markdown.rs b/src/markdown.rs index baf0e26..df64711 100644 --- a/src/markdown.rs +++ b/src/markdown.rs @@ -33,6 +33,14 @@ fn convert_hyphens_to_em_dashes(mut content: String) -> String { content.trim().to_string() } +/// Convert Smart Quotes to straight quotes +fn convert_smart_quotes(mut content: String) -> String { + let re = Regex::new(r"(“|”)").unwrap(); + content = Regex::replace_all(&re, content.as_str(), "\"").to_string(); + + content.trim().to_string() +} + /// Convert the content of a Markdown into a collection of paragraphs. fn content_to_paragraphs(mut content: String) -> Vec { // Pre-process the content @@ -43,6 +51,9 @@ fn content_to_paragraphs(mut content: String) -> Vec { // Replace double-hyphens to em-dashes content = convert_hyphens_to_em_dashes(content); + // Convert smart quotes to straight quotes + content = convert_smart_quotes(content); + let mut paragraphs: Vec = vec![]; let sep = Paragraph::new() .add_run(Run::new().add_text("#")) @@ -330,6 +341,15 @@ mod tests { assert!(content.is_empty()); } + #[test] + fn test_convert_smart_quotes() { + let content = convert_smart_quotes( + "“Go home,” Gabriel said.".to_string(), + ); + println!("{content}"); + assert!(content == "\"Go home,\" Gabriel said."); + } + #[test] fn test_convert_hyphens_to_em_dashes() { let content = convert_hyphens_to_em_dashes( From 3d40590ec031432ba71d9f80ece569d312cb9e78 Mon Sep 17 00:00:00 2001 From: Adam Israel Date: Sat, 8 Aug 2026 11:16:13 -0400 Subject: [PATCH 2/2] fix(lint) --- src/markdown.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/markdown.rs b/src/markdown.rs index df64711..ea78846 100644 --- a/src/markdown.rs +++ b/src/markdown.rs @@ -343,9 +343,7 @@ mod tests { #[test] fn test_convert_smart_quotes() { - let content = convert_smart_quotes( - "“Go home,” Gabriel said.".to_string(), - ); + let content = convert_smart_quotes("“Go home,” Gabriel said.".to_string()); println!("{content}"); assert!(content == "\"Go home,\" Gabriel said."); }