summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/recite.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/recite.rs b/src/recite.rs
index 9860eff..a655aa7 100644
--- a/src/recite.rs
+++ b/src/recite.rs
@@ -609,6 +609,28 @@ impl Poem {
word.clear();
}
+ // The character is a newline (may happen if parsing from a file)
+ Some(char) if char == '\n' => {
+ // If there are chars on the word stack, push that word
+ // onto the stanza
+ if !word.is_empty() {
+ stanza.push(word.iter().collect());
+ }
+
+ // A newline indicates the end of a verse
+ if !stanza.is_empty() {
+ verses.push(Verse::new(
+ Stanza::new(stanza.clone()),
+ Meter::String,
+ Verse::couplet(prev),
+ ));
+ }
+
+ // Clear the stacks
+ stanza.clear();
+ word.clear();
+ }
+
// The character is whitespace
Some(char) if char == ' ' || char == '\t' => {
// If there are chars on the word stack, push that word