rustyphoenixlecture 2.2.2

HTML lectures generation
/***************************************
	Auteur : Pierre Aubert
	Mail : pierre.aubert@lapp.in2p3.fr
	Licence : LGPL-3.0-only
****************************************/

///Strip the html markers in the given string
/// # Parameters
/// - `input_str` : input string to be stripped
/// # Returns
/// String without html marker
pub fn phoenix_strip_html(input_str: &String) -> String{
	// Here we assume the html is well formated
	// let vec_str: Vec<&str> = input_str.split_terminator(&['<', '>'][..]).collect();
	let mut output_str = String::from("");
	let mut is_in_marker = false;
	let open_marker: char = '<' as char;
	let close_marker: char = '>' as char;
	//I have no word to express how stupid Rust is at this point. into_bytes promise you that no copy is needed but Rust forces you to do a copy even if it is not supposed to be mandatory ????!!!!
	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 the phoenix_strip_html
	#[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"));
	}
}