trim instead of replace

This commit is contained in:
Dmitry Belyaev 2022-09-23 22:37:17 +03:00
parent fbca249149
commit 9d1885b245
Signed by: b4tman
GPG Key ID: 41A00BF15EA7E5F3

View File

@ -204,7 +204,7 @@ impl QuestionsParser {
self.last_keyword_type = self.cur_keyword_type; self.last_keyword_type = self.cur_keyword_type;
self.last_tag = self.cur_tag.clone(); self.last_tag = self.cur_tag.clone();
self.cur_keyword_type = Some(keyword.parse().unwrap()); self.cur_keyword_type = Some(keyword.parse().unwrap());
self.cur_tag = keyword.replace(' ', "").replace(':', ""); self.cur_tag = keyword.trim_end().trim_end_matches(':').to_string();
} }
/// if line matched keyword /// if line matched keyword
fn on_keyword_match(&mut self, line: &str, keyword: &str) { fn on_keyword_match(&mut self, line: &str, keyword: &str) {
@ -212,7 +212,7 @@ impl QuestionsParser {
// remember question id // remember question id
if let Some(KeywordType::QuestionStart) = self.cur_keyword_type { if let Some(KeywordType::QuestionStart) = self.cur_keyword_type {
self.cur_question_pre["id"] = line.replace(':', "").into(); self.cur_question_pre["id"] = line.trim_end().trim_end_matches(':').into();
}; };
self.apply_content_for_last_keyword(); self.apply_content_for_last_keyword();