Struct texcore::element::ElementList
source · pub struct ElementList<T: Tex> { /* private fields */ }
Expand description
A linked list of elements
Implementations§
source§impl ElementList<Any>
impl ElementList<Any>
sourcepub fn new(metadata: &Metadata) -> Self
pub fn new(metadata: &Metadata) -> Self
Creates a new empty list
Examples found in repository?
examples/doc_example.rs (line 9)
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
fn main() -> Result<(), Error> {
let metadata = Metadata::new("Author", "date", "title", 11, "book", true);
let mut list = ElementList::new(&metadata);
let part = Part::new("part");
let chapter = Chapter::new("chapter");
let header1 = Header::new("header1", 1);
let header2 = Header::new("header2", 2);
let text = Text::new("text", TextType::Normal);
let pkg = Package::new("dramatist");
list.push_array(Elements![part, chapter, header1, header2, text, pkg]);
/*
To compile, use the `compile` feature
list.compile(PathBuf::from("test.pdf");
To write to single tex file:
list.write(PathBuf::from("test.tex"))?;
To split write Packages and Main file:
list.write_split(PathBuf::from("main.tex"), PathBuf::from("structure.tex"))?;
To print:
list.print_tex();
*/
Ok(())
}
sourcepub fn add_newpage(&mut self)
pub fn add_newpage(&mut self)
Adds in \newpage
text as next element in the list
sourcepub fn push_array(&mut self, element_vec: Vec<Element<Any>>)
pub fn push_array(&mut self, element_vec: Vec<Element<Any>>)
Pushes an element vector into the list
Examples found in repository?
examples/doc_example.rs (line 16)
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
fn main() -> Result<(), Error> {
let metadata = Metadata::new("Author", "date", "title", 11, "book", true);
let mut list = ElementList::new(&metadata);
let part = Part::new("part");
let chapter = Chapter::new("chapter");
let header1 = Header::new("header1", 1);
let header2 = Header::new("header2", 2);
let text = Text::new("text", TextType::Normal);
let pkg = Package::new("dramatist");
list.push_array(Elements![part, chapter, header1, header2, text, pkg]);
/*
To compile, use the `compile` feature
list.compile(PathBuf::from("test.pdf");
To write to single tex file:
list.write(PathBuf::from("test.tex"))?;
To split write Packages and Main file:
list.write_split(PathBuf::from("main.tex"), PathBuf::from("structure.tex"))?;
To print:
list.print_tex();
*/
Ok(())
}
sourcepub fn to_latex_string(&mut self) -> String
pub fn to_latex_string(&mut self) -> String
Walks the list and returns a combined latex string
sourcepub fn to_latex_split_string(&mut self) -> (String, String)
pub fn to_latex_split_string(&mut self) -> (String, String)
Walks the list and returns a split latex string separating Packages level
sourcepub fn write(&mut self, main: PathBuf) -> Result<(), Error>
pub fn write(&mut self, main: PathBuf) -> Result<(), Error>
Writes ElementList
into a latex file
sourcepub fn write_split(
&mut self,
main: PathBuf,
structure: PathBuf
) -> Result<(), Error>
pub fn write_split(
&mut self,
main: PathBuf,
structure: PathBuf
) -> Result<(), Error>
Writes ElementList
into two latex files splitting the main
content and structure
path for packages
sourcepub fn list_to_array(&self) -> Vec<Element<Any>>
pub fn list_to_array(&self) -> Vec<Element<Any>>
Returns &self.list to Vec<Element<Any>>
Trait Implementations§
source§impl<T: Clone + Tex> Clone for ElementList<T>
impl<T: Clone + Tex> Clone for ElementList<T>
source§fn clone(&self) -> ElementList<T>
fn clone(&self) -> ElementList<T>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Default for ElementList<Any>
impl Default for ElementList<Any>
source§impl<'de, T> Deserialize<'de> for ElementList<T>where
T: Deserialize<'de> + Tex,
impl<'de, T> Deserialize<'de> for ElementList<T>where
T: Deserialize<'de> + Tex,
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl<T: PartialEq + Tex> PartialEq<ElementList<T>> for ElementList<T>
impl<T: PartialEq + Tex> PartialEq<ElementList<T>> for ElementList<T>
source§fn eq(&self, other: &ElementList<T>) -> bool
fn eq(&self, other: &ElementList<T>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl<T: PartialOrd + Tex> PartialOrd<ElementList<T>> for ElementList<T>
impl<T: PartialOrd + Tex> PartialOrd<ElementList<T>> for ElementList<T>
source§fn partial_cmp(&self, other: &ElementList<T>) -> Option<Ordering>
fn partial_cmp(&self, other: &ElementList<T>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read more