Skip to content

Commit

Permalink
feat(proc): add ProcReferences
Browse files Browse the repository at this point in the history
Add a struct to handle intermediately rendered output.

The intention is something similar to the haskell citeproc server json.

Signed-off-by: Bruce D'Arcus <bdarcus@gmail.com>
  • Loading branch information
bdarcus committed Oct 15, 2023
1 parent 8a377cd commit 2b92223
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions processor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SPDX-FileCopyrightText: © 2023 Bruce D'Arcus

use csln::bibliography::reference::InputReference;
use csln::bibliography::reference::{EdtfString, RefID};
use csln::bibliography::InputBibliography as Bibliography;
use csln::bibliography::{self, InputBibliography as Bibliography};

Check warning on line 8 in processor/src/lib.rs

View workflow job for this annotation

GitHub Actions / Check

unused import: `self`

Check warning on line 8 in processor/src/lib.rs

View workflow job for this annotation

GitHub Actions / Check

unused import: `self`

Check failure on line 8 in processor/src/lib.rs

View workflow job for this annotation

GitHub Actions / Lints

unused import: `self`

Check failure on line 8 in processor/src/lib.rs

View workflow job for this annotation

GitHub Actions / Lints

unused import: `self`

Check warning on line 8 in processor/src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite

unused import: `self`

Check warning on line 8 in processor/src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Suite

unused import: `self`
use csln::citation::Citation;
use csln::style::locale::Locale;
use csln::style::options::{Config, MonthFormat, SortKey, SubstituteKey};
Expand Down Expand Up @@ -619,15 +619,23 @@ impl ComponentValues for TemplateDate {
// assert_eq!(rendered_date, "2020");
// }

/// The intermediate representation of renderered citations and bibliography..
#[derive(Debug, Deserialize, Serialize, Clone, JsonSchema)]
pub struct ProcReferences {
pub bibliography: Vec<ProcTemplate>,
pub citations: Option<Vec<ProcTemplate>>,
}

impl Processor {
/// Render references to AST.
#[inline]
pub fn process_references(&self) -> Vec<ProcTemplate> {
pub fn process_references(&self) -> ProcReferences {
let sorted_references = self.sort_references(self.get_references());
sorted_references
let bibliography = sorted_references
.par_iter()
.map(|reference| self.process_reference(reference))
.collect()
.collect();
ProcReferences { bibliography, citations: None }
}

/// Render a reference to AST.
Expand Down

0 comments on commit 2b92223

Please sign in to comment.