Skip to main content

Renderer

Struct Renderer 

Source
pub struct Renderer<'a> {
Show 15 fields pub style: &'a Style, pub bibliography: &'a Bibliography, pub locale: &'a Locale, pub config: &'a Config, pub bibliography_config: Option<BibliographyConfig>, pub hints: &'a HashMap<String, ProcHints>, pub citation_numbers: &'a RefCell<HashMap<String, usize>>, pub compound_set_by_ref: &'a HashMap<String, String>, pub compound_member_index: &'a HashMap<String, usize>, pub compound_sets: &'a IndexMap<String, Vec<String>>, pub show_semantics: bool, pub inject_ast_indices: bool, pub filtered_to_original_index: RefCell<Option<Vec<usize>>>, pub abbreviation_map: Option<&'a AbbreviationMap>, pub first_note_by_id: Option<&'a RefCell<HashMap<String, u32>>>,
}
Expand description

The renderer for citation and bibliography templates.

The Renderer is responsible for taking compiled templates and applying them to bibliographic data, handling localization, numbering, and formatting.

Fields§

§style: &'a Style

The style definition containing templates and options.

§bibliography: &'a Bibliography

The bibliography containing the reference data.

§locale: &'a Locale

The locale used for terms and formatting.

§config: &'a Config

The active configuration options.

§bibliography_config: Option<BibliographyConfig>

The active bibliography-only configuration.

§hints: &'a HashMap<String, ProcHints>

Pre-calculated hints for optimization.

§citation_numbers: &'a RefCell<HashMap<String, usize>>

Shared state for citation numbers (used in numeric styles).

§compound_set_by_ref: &'a HashMap<String, String>

Optional compound set membership indexed by reference id.

§compound_member_index: &'a HashMap<String, usize>

Optional 0-based member index within each compound set.

§compound_sets: &'a IndexMap<String, Vec<String>>

Compound sets keyed by set id.

§show_semantics: bool

Whether to output semantic markup (HTML spans, Djot attributes).

§inject_ast_indices: bool

Whether to attach source template indices to rendered semantic wrappers.

§filtered_to_original_index: RefCell<Option<Vec<usize>>>

Mapping from filtered to original template indices (for grouped citations).

§abbreviation_map: Option<&'a AbbreviationMap>

Document-level abbreviation map for post-render substitution.

§first_note_by_id: Option<&'a RefCell<HashMap<String, u32>>>

First note number per reference id (populated by normalize_note_context).

Implementations§

Source§

impl Renderer<'_>

Source

pub fn render_grouped_citation( &self, items: &[CitationItem], spec: &CitationSpec, mode: &CitationMode, intra_delimiter: &str, suppress_author: bool, position: Option<&Position>, ) -> Result<Vec<String>, ProcessorError>

Render citation items with author grouping, using plain text format.

§Errors

Returns an error when a referenced item is missing or grouped rendering fails.

Source

pub fn render_grouped_citation_with_format<F>( &self, items: &[CitationItem], params: &GroupRenderParams<'_>, ) -> Result<Vec<String>, ProcessorError>
where F: OutputFormat<Output = String>,

This preserves per-item output when grouping rules require items to stay separate, and otherwise applies the requested renderer format to the grouped citation output.

§Errors

Returns an error when a referenced item is missing or grouped rendering fails.

Source

pub fn get_or_assign_citation_number(&self, ref_id: &str) -> usize

Get the citation number for a reference, assigning one if not yet cited.

Source

pub fn process_bibliography_entry( &self, reference: &Reference, entry_number: usize, ) -> Option<ProcTemplate>

Process a bibliography entry.

Source

pub fn process_bibliography_entry_with_format<F>( &self, reference: &Reference, entry_number: usize, ) -> Option<ProcTemplate>
where F: OutputFormat<Output = String>,

Process a bibliography entry with specific format.

Source

pub fn process_template_with_number( &self, reference: &Reference, params: TemplateRenderParams<'_>, ) -> Option<ProcTemplate>

Process a template for a reference using plain text format.

Accepts a TemplateRenderParams bundle rather than individual arguments to keep the call site readable and avoid argument-count lint issues.

Source

pub fn process_template_with_number_with_format<F>( &self, reference: &Reference, params: TemplateRenderParams<'_>, ) -> Option<ProcTemplate>
where F: OutputFormat<Output = String>,

Process a template for a reference with a specific output format.

Accepts a TemplateRenderParams bundle rather than individual arguments to keep the call site readable and avoid argument-count lint issues.

Source

pub fn process_template_request_with_format<F>( &self, reference: &Reference, request: TemplateRenderRequest<'_>, ) -> Option<ProcTemplate>
where F: OutputFormat<Output = String>,

Process a template request with a specific output format.

Source

pub fn apply_author_substitution( &self, proc: &mut ProcTemplate, substitute: &str, )

Apply the substitution string to the primary contributor component.

Source

pub fn apply_author_substitution_with_format<F>( &self, proc: &mut ProcTemplate, substitute: &str, )
where F: OutputFormat<Output = String>,

Apply the substitution string to the primary contributor component with specific format.

Source§

impl<'a> Renderer<'a>

Source

pub fn new( resources: RendererResources<'a>, hints: &'a HashMap<String, ProcHints>, citation_numbers: &'a RefCell<HashMap<String, usize>>, compound: CompoundRenderData<'a>, show_semantics: bool, inject_ast_indices: bool, abbreviation_map: Option<&'a AbbreviationMap>, ) -> Self

Creates a new Renderer instance.

Source

pub fn render_ungrouped_citation( &self, items: &[CitationItem], spec: &CitationSpec, mode: &CitationMode, intra_delimiter: &str, suppress_author: bool, position: Option<&Position>, ) -> Result<Vec<String>, ProcessorError>

Render citation items without grouping, using plain text format.

§Errors

Returns an error when a referenced item is missing or item rendering fails.

Source

pub fn render_ungrouped_citation_with_format<F>( &self, items: &[CitationItem], spec: &CitationSpec, mode: &CitationMode, intra_delimiter: &str, suppress_author: bool, position: Option<&Position>, note_start_text_case: Option<NoteStartTextCase>, ) -> Result<Vec<String>, ProcessorError>
where F: OutputFormat<Output = String>,

Render citation items without grouping, generic over the output format.

This is the core logic for iterating over citation items, looking up references, and applying the appropriate template or fallback logic.

§Errors

Returns an error when a referenced item is missing or item rendering fails.

Auto Trait Implementations§

§

impl<'a> !Freeze for Renderer<'a>

§

impl<'a> !RefUnwindSafe for Renderer<'a>

§

impl<'a> !Send for Renderer<'a>

§

impl<'a> !Sync for Renderer<'a>

§

impl<'a> !UnwindSafe for Renderer<'a>

§

impl<'a> Unpin for Renderer<'a>

§

impl<'a> UnsafeUnpin for Renderer<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.