Finished tests on the gemtext parser, revealing yet another bug which
was also fixed.
This commit is contained in:
parent
608d63def9
commit
ef67fe7aa1
2 changed files with 52 additions and 1 deletions
|
@ -138,6 +138,14 @@ impl<'a> Parser<'a> {
|
||||||
State::Quote(_) => self.parse_quote(line),
|
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
|
self.lines
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,6 +327,48 @@ mod tests {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
nodes.next().cloned().unwrap(),
|
nodes.next().cloned().unwrap(),
|
||||||
GemtextNode::Timestamp("2023-06-07T21:27:15Z".to_string()),
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,5 +8,6 @@ The new album's in the can. A few things:
|
||||||
* Needs more cowbell
|
* Needs more cowbell
|
||||||
* Adrian's guitar is too loud, drowning out the cowbell
|
* Adrian's guitar is too loud, drowning out the cowbell
|
||||||
* Steve has a fever
|
* Steve has a fever
|
||||||
|
=> gemini://private.iron.maiden/clip.mp3 clip
|
||||||
|
|
||||||
> You're gonna want that cowbell!
|
> You're gonna want that cowbell!
|
||||||
|
|
Loading…
Add table
Reference in a new issue