Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
benmanone committed Jun 7, 2023
1 parent e946c5e commit a2d7752
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repository = "https://github.com/benmanone/minicloze/"
readme = "README.md"
authors = ["benman"]
license = "WTFPL"
version = "1.3.0"
version = "1.3.1"
edition = "2021"

[dependencies]
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ www.crates.io/crates/rand

www.crates.io/crates/open

www.crates.io/crates/levenshtein

# Contributing
Any help is very welcome, just open a PR or an issue and I'll probably be able to reply quickly. Right now the focus is on expanding from the basic idea into a more fully-fledged and user friendly experience.

Expand Down
10 changes: 6 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ fn start_game(sentences: Vec<Sentence>, len: usize, language: String, previous_c
let gap_index: usize;

if is_non_spaced {
let char_strings = translation.chars().map(|x| x.to_string());
let char_strings = translation.trim().chars().map(|x| x.to_string());
words = char_strings.collect::<String>();
gap_index = rng.gen_range(0..translation.chars().count());
raw_word = translation
Expand All @@ -127,8 +127,8 @@ fn start_game(sentences: Vec<Sentence>, len: usize, language: String, previous_c
.unwrap()
.to_string();
} else {
words = translation.split_inclusive(' ').collect::<String>();
let length = translation.split_inclusive(' ').count();
words = translation.trim().split_inclusive(' ').collect::<String>();
let length = translation.trim().split_inclusive(' ').count();
gap_index = rng.gen_range(0..length);
raw_word = translation
.split_inclusive(' ')
Expand All @@ -138,9 +138,11 @@ fn start_game(sentences: Vec<Sentence>, len: usize, language: String, previous_c
.to_string();
}

println!();

let word = raw_word.replace(
&[
'(', ')', ',', '.', ';', ':', '?', '¿', '!', '¡', '"', '\'', '«', '»',
'(', ')', ',', '.', ';', ':', '?', '¿', '!', '¡', '"', '«', '»',
][..],
"",
);
Expand Down

0 comments on commit a2d7752

Please sign in to comment.