rustyphoenixlecture 1.1.0

This project aims to provide a simple a powerfull lecture compilation to generate html web sites
/***************************************
	Auteur : Pierre Aubert
	Mail : pierre.aubert@lapp.in2p3.fr
	Licence : CeCILL-C
****************************************/

use crate::plectureparser::{
	PReferenceUrl,
	pabstractcontent::{PAbstractContent, PAbstractLectureBackend},
	plabeler::PLabelId,
};

///Text Content object of the lecture
#[derive(Debug, Clone, PartialEq)]
pub struct PContentText{
	///Text content
	text: String,
}

impl PContentText {
	///Constructor of a PContentText
	/// # Parameters
	/// - `text` : text of the content
	pub fn new(text: &String) -> Self{
		PContentText {
			text: text.clone(),
		}
	}
	///Append text into the PContentText
	/// # Parameters
	/// - `text` : text to be appended into the PContentText
	pub fn add_text(&mut self, text: &String){
		self.text += &text;
	}
}

impl PAbstractContent for PContentText{
	///Say if the PContent has an embeded label
	/// # Returns
	/// True if the PContent has an embeded label, false otherwise
	fn has_embeded_label(&self) -> bool{
		false
	}
	///Get the reference url of the current PContent
	/// # Parameters
	/// - `current_file` : current output file of the PContent
	/// - `id` : id of the PContent
	/// # Returns
	/// Corresponding PReferenceUrl
	fn get_reference_url(&self, current_file: &String, id: usize) -> PReferenceUrl{
		PReferenceUrl::from_text(current_file, id, &String::from(format!("Text {}", id)))
	}
	///Convert the current struct into html
	/// # Parameters
	/// - `backend` : backend which write a lecture in files
	/// - `_id` : id of the PContent
	fn to_html<TLectureBackend>(&self, backend: &mut TLectureBackend, _id: &PLabelId)
		where TLectureBackend: PAbstractLectureBackend
	{
		backend.write(&self.text);
	}
}

#[cfg(test)]
mod tests{
	use super::*;
	use crate::plectureparser::pstrbackend::PStrBackend;
	
	///Test the PContentText
	#[test]
	fn test_content_text(){
		let text: PContentText = PContentText::new(&String::from("Some text"));
		let mut backend = PStrBackend::new();
		text.to_html(&mut backend, &PLabelId::new(42));
		assert_eq!(backend.get_body(), &String::from("Some text"));
	}
}