@@ -246,7 +246,9 @@ pub fn extract_image_references(input: &str) -> (String, Vec<ImageReference>) {
246246
247247 while let Some ( ch) = chars. next ( ) {
248248 match ch {
249- '"' | '\'' if !in_quotes => {
249+ // Only treat quotes as delimiters if we're at a word boundary (current_word is empty)
250+ // This prevents apostrophes in contractions like "don't" from being treated as quotes
251+ '"' | '\'' if !in_quotes && current_word. is_empty ( ) => {
250252 in_quotes = true ;
251253 quote_char = ch;
252254 }
@@ -535,4 +537,22 @@ mod tests {
535537 ) ;
536538 assert_eq ! ( text, "" ) ;
537539 }
540+
541+ #[ test]
542+ fn test_contractions_dont_break_parsing ( ) {
543+ // Contractions like "don't", "it's", "we're" should not be treated as quoted strings
544+ let ( text, refs) = extract_image_references ( "I don't see image.png it's missing" ) ;
545+ assert_eq ! ( refs. len( ) , 1 , "Should detect image despite contractions" ) ;
546+ assert ! ( matches!( & refs[ 0 ] , ImageReference :: LocalPath ( p) if p == "image.png" ) ) ;
547+ assert ! ( text. contains( "don't" ) , "Should preserve don't" ) ;
548+ assert ! ( text. contains( "it's" ) , "Should preserve it's" ) ;
549+
550+ // Multiple contractions
551+ let ( text, refs) =
552+ extract_image_references ( "We're viewing photo.jpg and it's nice but there's more" ) ;
553+ assert_eq ! ( refs. len( ) , 1 ) ;
554+ assert ! ( text. contains( "We're" ) ) ;
555+ assert ! ( text. contains( "it's" ) ) ;
556+ assert ! ( text. contains( "there's" ) ) ;
557+ }
538558}
0 commit comments