From e094aad8d075736d4563a498a7aaac228413a9d1 Mon Sep 17 00:00:00 2001 From: Mohamed Tarek Date: Wed, 2 Oct 2024 03:57:53 +0300 Subject: [PATCH] Trim whitespaces in keywords --- src/core/funcs.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/core/funcs.rs b/src/core/funcs.rs index 9329787..29c0f03 100644 --- a/src/core/funcs.rs +++ b/src/core/funcs.rs @@ -22,7 +22,7 @@ impl Fns { keyword.replace(&format!(":{}", func_name), "") } - /// This method finds `functions` in a string based on a Regex pattern that matches keywords with functions + /// This method finds `functions` in a string based on a Regex pattern that matches keywords pub fn find( txt: String, keywords: &HashMap, @@ -35,13 +35,15 @@ impl Fns { let keyword = key.as_str().to_string(); if !keywords.contains_key(&keyword) { - let data = keyword.as_str().split(':').collect::>(); + let new_keyword = Keywords::strip(keyword.clone()).trim().to_string(); + let data = new_keyword.split(':').collect::>(); if data.len() == 2 { let keyword_name = Keywords::strip(data[0].to_string()); - let func = data[1].replace("}}", ""); + let func = data[1].trim(); - match func.as_str() { + //TODO: handle the whitespaces better than this + match func { "read" => { found.insert(keyword_name, (keyword, Self::Read)); }