pub fn phoenix_strip_html(input_str: &String) -> String{
let mut output_str = String::from("");
let mut is_in_marker = false;
let open_marker: char = '<' as char;
let close_marker: char = '>' as char;
for ch in input_str.clone().chars().into_iter(){
if is_in_marker {
if ch == close_marker {
is_in_marker = false;
}
}else{
if ch == open_marker {
is_in_marker = true;
}else{
output_str += &String::from(ch);
}
}
}
return output_str;
}
#[cfg(test)]
mod tests{
use super::*;
#[test]
fn test_phoenix_strip_html(){
assert_eq!(phoenix_strip_html(&String::from("Nothing particular")), String::from("Nothing particular"));
assert_eq!(phoenix_strip_html(&String::from("Some <b>bold</b> in the text")), String::from("Some bold in the text"));
assert_eq!(phoenix_strip_html(&String::from("Some <span class=\"dsType\">unsigned int</b> in the text")), String::from("Some unsigned int in the text"));
assert_eq!(phoenix_strip_html(&String::from("Une équipe qui déchire")), String::from("Une équipe qui déchire"));
}
}