diff --git a/src/gemtext/parser.rs b/src/gemtext/parser.rs index 42a9955..ee08f0c 100644 --- a/src/gemtext/parser.rs +++ b/src/gemtext/parser.rs @@ -138,6 +138,14 @@ impl<'a> Parser<'a> { State::Quote(_) => self.parse_quote(line), } } + match self.state { + State::Normal => {} + State::Preformatted(_) => self.leave_preformatted(), + State::Quote(q) => { + let quote = q.join("\n").to_string(); + self.lines.push(GemtextNode::Quote(quote)); + } + } self.lines } @@ -319,6 +327,48 @@ mod tests { assert_eq!( nodes.next().cloned().unwrap(), GemtextNode::Timestamp("2023-06-07T21:27:15Z".to_string()), - ) + ); + assert_eq!( + nodes.next().cloned().unwrap(), + GemtextNode::Text("".to_string()), + ); + assert_eq!( + nodes.next().cloned().unwrap(), + GemtextNode::Heading1("Checking in".to_string()), + ); + assert_eq!( + nodes.next().cloned().unwrap(), + GemtextNode::Text("The new album's in the can. A few things:".to_string()), + ); + assert_eq!( + nodes.next().cloned().unwrap(), + GemtextNode::ListItem("Needs more cowbell".to_string()), + ); + assert_eq!( + nodes.next().cloned().unwrap(), + GemtextNode::ListItem( + "Adrian's guitar is too loud, drowning out the cowbell".to_string() + ), + ); + assert_eq!( + nodes.next().cloned().unwrap(), + GemtextNode::ListItem("Steve has a fever".to_string()), + ); + assert_eq!( + nodes.next().cloned().unwrap(), + GemtextNode::Link(Link { + url: "gemini://private.iron.maiden/clip.mp3".to_string(), + display: Some("clip".to_string()) + }) + ); + assert_eq!( + nodes.next().cloned().unwrap(), + GemtextNode::Text("".to_string()), + ); + assert_eq!( + nodes.next().cloned().unwrap(), + GemtextNode::Quote("You're gonna want that cowbell!".to_string()), + ); + assert!(nodes.next().is_none()); } } diff --git a/test/mailstore/misfin.example.org/jane/Lists/700070.gmi b/test/mailstore/misfin.example.org/jane/Lists/700070.gmi index 27977f0..78dc6c7 100644 --- a/test/mailstore/misfin.example.org/jane/Lists/700070.gmi +++ b/test/mailstore/misfin.example.org/jane/Lists/700070.gmi @@ -8,5 +8,6 @@ The new album's in the can. A few things: * Needs more cowbell * Adrian's guitar is too loud, drowning out the cowbell * Steve has a fever +=> gemini://private.iron.maiden/clip.mp3 clip > You're gonna want that cowbell!