citum-engine 0.60.0

Citum citation and bibliography processor
Documentation
/*
SPDX-License-Identifier: MIT OR Apache-2.0
SPDX-FileCopyrightText: © 2023-2026 Bruce D'Arcus and Citum contributors
*/

#![allow(missing_docs, reason = "test")]
#![allow(
    clippy::unwrap_used,
    clippy::expect_used,
    clippy::panic,
    clippy::indexing_slicing,
    clippy::todo,
    clippy::unimplemented,
    clippy::unreachable,
    clippy::get_unwrap,
    reason = "Panicking is acceptable and often desired in test, benchmark, and example code."
)]

use citum_engine::processor::Processor;
use citum_engine::render::latex::Latex;
use citum_schema::{
    Style,
    citation::{Citation, CitationItem, CitationMode},
};
use std::fs;
use std::path::Path;

#[allow(clippy::cognitive_complexity, reason = "macro-heavy output code")]
fn main() {
    let style_str = fs::read_to_string("styles/embedded/apa-7th.yaml").unwrap();
    let style: Style = serde_yaml::from_str(&style_str).unwrap();

    let bib = citum_io::load_bibliography(Path::new("bindings/latex/example-refs.yaml")).unwrap();
    let processor = Processor::new(style, bib);

    let cite = Citation {
        id: Some("cite1".into()),
        mode: CitationMode::NonIntegral,
        position: None,
        suppress_author: false,
        prefix: None,
        suffix: None,
        note_number: None,
        grouped: false,
        items: vec![CitationItem {
            id: "weinberg1971".to_string(),
            locator: None,
            prefix: None,
            suffix: None,
            integral_name_state: None,
            org_abbreviation_state: None,
        }],
    };

    match processor.process_citation_with_format::<Latex>(&cite) {
        Ok(res) => tracing::debug!("CITATION: {res}"),
        Err(e) => tracing::debug!("ERROR: {e:?}"),
    }

    // Try suppress author just in case
    let cite_sa = Citation {
        mode: CitationMode::NonIntegral,
        suppress_author: true,
        ..cite.clone()
    };
    match processor.process_citation_with_format::<Latex>(&cite_sa) {
        Ok(res) => tracing::debug!("CITATION SA: {res}"),
        Err(e) => tracing::debug!("ERROR: {e:?}"),
    }
}