rustyphoenixlecture 1.7.2

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::pcontent::{
	pabstractcontent::{PAbstractContent, PAbstractLectureBackend},
	plabeler::PLabelId,
	preferenceurl::PReferenceUrl,
	pveccontent::PVecContent
};

///Content object of the lecture
#[derive(Debug, Clone, Default, PartialEq)]
pub struct PContentStyle{
	///Style of the PContentStyle
	style: String,
	///Vector of children
	content: PVecContent,
}

impl PContentStyle {
	///Constructor of the PContentStyle
	/// # Parameters
	/// - `style` : css style of the PContentStyle
	/// # Returns
	/// Initialised PContentStyle
	pub fn new(style: &String) -> Self{
		PContentStyle {
			style: style.clone(),
			content: Default::default(),
		}
	}
	///Get the mutable content of the PContentStyleWorkInProgress
	/// # Returns
	/// Mutable content of the PContentStyleWorkInProgress
	pub fn get_content_mut(&mut self) -> &mut PVecContent {
		&mut self.content
	}
}

impl PAbstractContent for PContentStyle{
	///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 PContentStyle
	/// # Parameters
	/// - `current_file` : current output file of the PContentStyle
	/// - `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!("PContentStyle({}) {}", self.style, 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
	{
		if !self.style.is_empty(){
			backend.write(&String::from(format!("<span id=\"{}\" class=\"{}\">", id.get_id(), self.style)));
		}
		self.content.to_html(backend, id);
		if !self.style.is_empty(){
			backend.write(&String::from("</span>"));
		}
	}
}