From c06dc237a6c217cb03289a2a878e7a0b4c4200ec Mon Sep 17 00:00:00 2001 From: Max Bradbury Date: Thu, 30 Apr 2020 20:18:15 +0100 Subject: [PATCH] handle empty dialogue line (poorly...) --- src/game.rs | 3 ++- src/lib.rs | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/game.rs b/src/game.rs index 0a9dbb7..e3e51a0 100644 --- a/src/game.rs +++ b/src/game.rs @@ -247,7 +247,8 @@ impl ToString for Game { } for dialogue in &self.dialogues { - segments.push(dialogue.to_string()); + // this replacement is silly but see segments_from_string() for explanation + segments.push(dialogue.to_string().replace("\"\"\"\n\"\"\"", "")); } for ending in &self.endings { diff --git a/src/lib.rs b/src/lib.rs index 514b4ce..6d5c5dc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -115,6 +115,11 @@ fn transform_line_endings(input: String, mode: TransformMode) -> String { #[inline] fn segments_from_string(string: String) -> Vec { + // this is pretty weird but a dialogue can just have an empty line followed by a name + // however, on entering two empty lines, dialogue will be wrapped in triple quotation marks + // so, handle this here + let string = string.replace("\n\nNAME", "\n\"\"\"\n\"\"\"\nNAME"); + let mut output:Vec = Vec::new(); // are we inside `"""\n...\n"""`? if so, ignore empty lines let mut inside_escaped_block = false;