File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -463,7 +463,11 @@ pub fn extract_messages(document: &str) -> Vec<(usize, String)> {
463463 Group :: Translate ( events) => {
464464 if let Some ( ( lineno, _) ) = events. first ( ) {
465465 let ( text, new_state) = reconstruct_markdown ( events, state) ;
466- messages. push ( ( * lineno, text) ) ;
466+ // Skip empty messages since they are special:
467+ // they contains the PO file metadata.
468+ if !text. trim ( ) . is_empty ( ) {
469+ messages. push ( ( * lineno, text) ) ;
470+ }
467471 state = Some ( new_state) ;
468472 }
469473 }
@@ -689,6 +693,16 @@ mod tests {
689693 assert_extract_messages ( "" , vec ! [ ] ) ;
690694 }
691695
696+ #[ test]
697+ fn extract_messages_empty_html ( ) {
698+ assert_extract_messages ( "<span></span>" , vec ! [ ] ) ;
699+ }
700+
701+ #[ test]
702+ fn extract_messages_whitespace_only ( ) {
703+ assert_extract_messages ( "<span> </span>" , vec ! [ ] ) ;
704+ }
705+
692706 #[ test]
693707 fn extract_messages_single_line ( ) {
694708 assert_extract_messages ( "This is a paragraph." , vec ! [ ( 1 , "This is a paragraph." ) ] ) ;
You can’t perform that action at this time.
0 commit comments