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 StyleThe style definition containing templates and options.
bibliography: &'a BibliographyThe bibliography containing the reference data.
locale: &'a LocaleThe locale used for terms and formatting.
config: &'a ConfigThe 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: boolWhether to output semantic markup (HTML spans, Djot attributes).
inject_ast_indices: boolWhether 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<'_>
impl Renderer<'_>
Sourcepub fn render_grouped_citation(
&self,
items: &[CitationItem],
spec: &CitationSpec,
mode: &CitationMode,
intra_delimiter: &str,
suppress_author: bool,
position: Option<&Position>,
) -> Result<Vec<String>, ProcessorError>
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.
Sourcepub fn render_grouped_citation_with_format<F>(
&self,
items: &[CitationItem],
params: &GroupRenderParams<'_>,
) -> Result<Vec<String>, ProcessorError>where
F: OutputFormat<Output = String>,
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.
Sourcepub fn get_or_assign_citation_number(&self, ref_id: &str) -> usize
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.
Sourcepub fn process_bibliography_entry(
&self,
reference: &Reference,
entry_number: usize,
) -> Option<ProcTemplate>
pub fn process_bibliography_entry( &self, reference: &Reference, entry_number: usize, ) -> Option<ProcTemplate>
Process a bibliography entry.
Sourcepub fn process_bibliography_entry_with_format<F>(
&self,
reference: &Reference,
entry_number: usize,
) -> Option<ProcTemplate>where
F: OutputFormat<Output = String>,
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.
Sourcepub fn process_template_with_number(
&self,
reference: &Reference,
params: TemplateRenderParams<'_>,
) -> Option<ProcTemplate>
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.
Sourcepub fn process_template_with_number_with_format<F>(
&self,
reference: &Reference,
params: TemplateRenderParams<'_>,
) -> Option<ProcTemplate>where
F: OutputFormat<Output = String>,
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.
Sourcepub fn process_template_request_with_format<F>(
&self,
reference: &Reference,
request: TemplateRenderRequest<'_>,
) -> Option<ProcTemplate>where
F: OutputFormat<Output = String>,
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.
Apply the substitution string to the primary contributor component.
Apply the substitution string to the primary contributor component with specific format.
Source§impl<'a> Renderer<'a>
impl<'a> Renderer<'a>
Sourcepub 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
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.
Sourcepub fn render_ungrouped_citation(
&self,
items: &[CitationItem],
spec: &CitationSpec,
mode: &CitationMode,
intra_delimiter: &str,
suppress_author: bool,
position: Option<&Position>,
) -> Result<Vec<String>, ProcessorError>
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.
Sourcepub 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>,
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.