From b4e05cdc1bd82b20a46084514febd416f55b9b04 Mon Sep 17 00:00:00 2001 From: Max Bradbury Date: Tue, 14 Apr 2020 00:34:03 +0100 Subject: [PATCH] trim whitespace around game data --- src/game.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/game.rs b/src/game.rs index aed95ba..87d111e 100644 --- a/src/game.rs +++ b/src/game.rs @@ -18,6 +18,14 @@ pub struct Game { impl From for 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 // otherwise, everything can be split on a double line break (\n\n) let mut dialogues: Vec = Vec::new();