Add formatting implementation for in_collection

Signed-off-by: trivernis <trivernis@protonmail.com>
feature/epub-rendering
trivernis 4 years ago
parent ef85637b59
commit d0ebeebbd5
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

6
Cargo.lock generated

@ -54,7 +54,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "bibliographix" name = "bibliographix"
version = "0.3.0" version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"chrono 0.4.15 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.15 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1145,7 +1145,7 @@ version = "0.23.0"
dependencies = [ dependencies = [
"asciimath-rs 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)", "asciimath-rs 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)",
"base64 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)",
"bibliographix 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "bibliographix 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"charred 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "charred 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"chrono 0.4.15 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.15 (registry+https://github.com/rust-lang/crates.io-index)",
"colored 1.9.3 (registry+https://github.com/rust-lang/crates.io-index)", "colored 1.9.3 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1588,7 +1588,7 @@ dependencies = [
"checksum atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" "checksum atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
"checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" "checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
"checksum base64 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" "checksum base64 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff"
"checksum bibliographix 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4d80a9410af7ce9fa988e4ea1944a84ab9b00ffadb9f380120b0bc18996fad4b" "checksum bibliographix 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "37feda13663b7ebab576b6d710c4c5b26f9e406556bdc60e38dd791bc7543e8d"
"checksum bincode 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f30d3a39baa26f9651f17b375061f3233dde33424a8b72b0dbe93a68a0bc896d" "checksum bincode 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f30d3a39baa26f9651f17b375061f3233dde33424a8b72b0dbe93a68a0bc896d"
"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" "checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
"checksum bumpalo 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820" "checksum bumpalo 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820"

@ -19,7 +19,7 @@ path = "src/main.rs"
[dependencies] [dependencies]
charred = "0.3.3" charred = "0.3.3"
asciimath-rs = "0.5.7" asciimath-rs = "0.5.7"
bibliographix = "0.3.0" bibliographix = "0.3.1"
crossbeam-utils = "0.7.2" crossbeam-utils = "0.7.2"
structopt = "0.3.14" structopt = "0.3.14"
minify = "1.1.1" minify = "1.1.1"

@ -4,6 +4,7 @@ use bibliographix::bibliography::bib_types::article::Article;
use bibliographix::bibliography::bib_types::book::Book; use bibliographix::bibliography::bib_types::book::Book;
use bibliographix::bibliography::bib_types::booklet::Booklet; use bibliographix::bibliography::bib_types::booklet::Booklet;
use bibliographix::bibliography::bib_types::in_book::InBook; use bibliographix::bibliography::bib_types::in_book::InBook;
use bibliographix::bibliography::bib_types::in_collection::InCollection;
use bibliographix::bibliography::bib_types::BibliographyType; use bibliographix::bibliography::bib_types::BibliographyType;
use bibliographix::bibliography::bibliography_entry::{ use bibliographix::bibliography::bibliography_entry::{
BibliographyEntry, BibliographyEntryReference, BibliographyEntry, BibliographyEntryReference,
@ -50,6 +51,7 @@ fn get_item_for_entry(entry: BibliographyEntryReference) -> ListItem {
BibliographyType::Book(b) => get_item_for_book(&*entry, b), BibliographyType::Book(b) => get_item_for_book(&*entry, b),
BibliographyType::Booklet(b) => get_item_for_booklet(&*entry, b), BibliographyType::Booklet(b) => get_item_for_booklet(&*entry, b),
BibliographyType::InBook(ib) => get_item_for_in_book(&*entry, ib), BibliographyType::InBook(ib) => get_item_for_in_book(&*entry, ib),
BibliographyType::InCollection(ic) => get_item_for_in_collection(&*entry, ic),
_ => unimplemented!(), _ => unimplemented!(),
} }
} }
@ -150,9 +152,8 @@ fn get_item_for_in_book(entry: &BibliographyEntry, ib: &InBook) -> ListItem {
.push(plain_text!(format!("{}.", ib.author.clone()))); .push(plain_text!(format!("{}.", ib.author.clone())));
text.subtext text.subtext
.push(plain_text!(format!("\"{}\"", ib.title.clone()))); .push(plain_text!(format!("\"{}\"", ib.title.clone())));
text.subtext text.subtext
.push(plain_text!(format!("({})", ib.position.clone()))); .push(plain_text!(format!(" ({})", ib.position.clone())));
if let Some(volume) = ib.volume.clone() { if let Some(volume) = ib.volume.clone() {
text.subtext.push(plain_text!(format!(", {}", volume))) text.subtext.push(plain_text!(format!(", {}", volume)))
@ -171,3 +172,35 @@ fn get_item_for_in_book(entry: &BibliographyEntry, ib: &InBook) -> ListItem {
ListItem::new(Line::Text(text), 0, true) ListItem::new(Line::Text(text), 0, true)
} }
fn get_item_for_in_collection(entry: &BibliographyEntry, ic: &InCollection) -> ListItem {
let mut text = TextLine::new();
text.subtext
.push(bold_text!(format!("{}: ", entry.key().clone())));
text.subtext
.push(plain_text!(format!("{}.", ic.author.clone())));
if let Some(editor) = ic.editor.clone() {
text.subtext
.push(plain_text!(format!("(Editor: {})", editor)))
}
text.subtext
.push(plain_text!(format!("\"{}\"", ic.title.clone())));
if let Some(position) = ic.position.clone() {
text.subtext.push(plain_text!(format!(" ({})", position)));
}
if let Some(volume) = ic.volume.clone() {
text.subtext.push(plain_text!(format!(", {}", volume)))
}
if let Some(edition) = ic.edition.clone() {
text.subtext.push(plain_text!(format!(", {}", edition)))
}
if let Some(series) = ic.series.clone() {
text.subtext.push(plain_text!("In: ".to_string()));
text.subtext.push(italic_text!(series))
}
ListItem::new(Line::Text(text), 0, true)
}

Loading…
Cancel
Save