From 9c87e72482b1f966666f94578d454992d6884a87 Mon Sep 17 00:00:00 2001 From: trivernis Date: Fri, 4 Sep 2020 18:41:27 +0200 Subject: [PATCH] Add formatting implementation for Thesis Signed-off-by: trivernis --- src/references/bibliography.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/references/bibliography.rs b/src/references/bibliography.rs index 445ccb6..3aad71e 100644 --- a/src/references/bibliography.rs +++ b/src/references/bibliography.rs @@ -9,6 +9,7 @@ use bibliographix::bibliography::bib_types::manual::Manual; use bibliographix::bibliography::bib_types::misc::Misc; use bibliographix::bibliography::bib_types::repository::Repository; use bibliographix::bibliography::bib_types::tech_report::TechReport; +use bibliographix::bibliography::bib_types::thesis::Thesis; use bibliographix::bibliography::bib_types::BibliographyType; use bibliographix::bibliography::bibliography_entry::{ BibliographyEntry, BibliographyEntryReference, @@ -60,6 +61,7 @@ fn get_item_for_entry(entry: BibliographyEntryReference) -> ListItem { BibliographyType::Misc(m) => get_item_for_misc(&*entry, m), BibliographyType::Repository(r) => get_item_for_repository(&*entry, r), BibliographyType::TechReport(tr) => get_item_for_tech_report(&*entry, tr), + BibliographyType::Thesis(t) => get_item_for_thesis(&*entry, t), _ => unimplemented!(), } } @@ -294,10 +296,12 @@ fn get_item_for_repository(entry: &BibliographyEntry, r: &Repository) -> ListIte ListItem::new(Line::Text(text), 0, true) } +/// Returns the list item for the tech report type fn get_item_for_tech_report(entry: &BibliographyEntry, tr: &TechReport) -> ListItem { let mut text = TextLine::new(); text.subtext .push(bold_text!(format!("{}: ", entry.key().clone()))); + text.subtext .push(plain_text!(format!("{}.", tr.author.clone()))); text.subtext @@ -309,3 +313,22 @@ fn get_item_for_tech_report(entry: &BibliographyEntry, tr: &TechReport) -> ListI ListItem::new(Line::Text(text), 0, true) } + +/// Returns a list item for a thesis +fn get_item_for_thesis(entry: &BibliographyEntry, t: &Thesis) -> ListItem { + let mut text = TextLine::new(); + text.subtext + .push(bold_text!(format!("{}: ", entry.key().clone()))); + text.subtext + .push(bold_text!(format!("{}: ", entry.key().clone()))); + text.subtext + .push(plain_text!(format!("{}.", t.author.clone()))); + text.subtext + .push(plain_text!(format!("\"{}\"", t.title.clone()))); + text.subtext + .push(plain_text!(format!("at {}", t.school.clone()))); + text.subtext + .push(plain_text!(format!(" on {}", t.date.format("%d.%m.%y")))); + + ListItem::new(Line::Text(text), 0, true) +}