From b9415ade9ede1bb950e79aecf3a7402da66a426a Mon Sep 17 00:00:00 2001 From: Max Bradbury Date: Fri, 6 Nov 2020 15:39:43 +0000 Subject: [PATCH] fix segments_from_str; version bump --- Cargo.toml | 2 +- src/game.rs | 4 ++-- src/lib.rs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index cc2ff90..3ee0617 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bitsy-parser" -version = "0.72.3" +version = "0.72.4" authors = ["Max Bradbury "] edition = "2018" description = "A parser and utilities for working with Bitsy game data" diff --git a/src/game.rs b/src/game.rs index fa023ab..8c9ef82 100644 --- a/src/game.rs +++ b/src/game.rs @@ -1,4 +1,4 @@ -use crate::{Dialogue, Ending, Font, Image, Item, Palette, Room, Sprite, TextDirection, Tile, Variable, transform_line_endings, segments_from_string, new_unique_id, try_id, Instance, Error}; +use crate::{Dialogue, Ending, Font, Image, Item, Palette, Room, Sprite, TextDirection, Tile, Variable, transform_line_endings, new_unique_id, try_id, Instance, Error}; use loe::TransformMode; @@ -125,7 +125,7 @@ impl Game { } let string = string.trim_start_matches('\n').to_string(); - let mut segments = segments_from_str(&string); + let mut segments = crate::segments_from_str(&string); let mut name = "".to_string(); diff --git a/src/lib.rs b/src/lib.rs index 2b95d01..0ce2677 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -108,11 +108,11 @@ fn transform_line_endings(input: String, mode: TransformMode) -> String { String::from_utf8(output.into_inner()).unwrap() } -fn segments_from_string(string: String) -> Vec { +fn segments_from_str(str: &str) -> 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 string = str.replace("\n\nNAME", "\n\"\"\"\n\"\"\"\nNAME"); let mut output:Vec = Vec::new(); // are we inside `"""\n...\n"""`? if so, ignore empty lines