diff --git a/src/lib.rs b/src/lib.rs index 4758e8f..2239496 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -103,8 +103,7 @@ mod tests { #[test] fn basic_text() { - let text = "Hello World!"; - let doc = parse(text); + let doc = parse("Hello World!"); let doc_ref = Document(vec![Node::Paragraph(vec![StyledText { italic: false, bold: false, @@ -115,4 +114,35 @@ mod tests { assert_eq!(doc, doc_ref); } + + /// Single paragraphs are allowed to include newlines; double + /// newlines, however, separate paragraphs. + #[test] + fn paragraphs() { + let doc = parse( + "\ +Hello +World! + +New paragraph", + ); + let doc_ref = Document(vec![ + Node::Paragraph(vec![StyledText { + italic: false, + bold: false, + underline: false, + color: None, + text: "Hello World!".to_string(), + }]), + Node::Paragraph(vec![StyledText { + italic: false, + bold: false, + underline: false, + color: None, + text: "New paragraph".to_string(), + }]), + ]); + + assert_eq!(doc, doc_ref); + } }