trim whitespace around game data

This commit is contained in:
Max Bradbury 2020-04-14 00:34:03 +01:00
parent cc347dbf99
commit b4e05cdc1b
1 changed files with 8 additions and 0 deletions

View File

@ -18,6 +18,14 @@ pub struct Game {
impl From<String> for Game { impl From<String> for Game {
fn from(string: String) -> Game { fn from(string: String) -> Game {
let mut string = format!("{}\n\n", string.trim());
if string.starts_with("# BITSY VERSION") {
string = format!("\n\n{}", string);
}
let string = string;
// dialogues and endings can have 2+ line breaks inside, so deal with these separately // dialogues and endings can have 2+ line breaks inside, so deal with these separately
// otherwise, everything can be split on a double line break (\n\n) // otherwise, everything can be split on a double line break (\n\n)
let mut dialogues: Vec<Dialogue> = Vec::new(); let mut dialogues: Vec<Dialogue> = Vec::new();