pub struct Processor {Show 17 fields
pub style: Style,
pub bibliography: Bibliography,
pub locale: Locale,
pub default_config: Config,
pub hints: HashMap<String, ProcHints>,
pub citation_numbers: RefCell<HashMap<String, usize>>,
pub cited_ids: RefCell<HashSet<String>>,
pub compound_sets: IndexMap<String, Vec<String>>,
pub compound_set_by_ref: HashMap<String, String>,
pub compound_member_index: HashMap<String, usize>,
pub compound_groups: RefCell<IndexMap<usize, Vec<String>>>,
pub dynamic_compound_set_by_ref: RefCell<HashMap<String, String>>,
pub dynamic_compound_member_index: RefCell<HashMap<String, usize>>,
pub dynamic_compound_sets: RefCell<IndexMap<String, Vec<String>>>,
pub show_semantics: bool,
pub inject_ast_indices: bool,
pub abbreviation_map: Option<AbbreviationMap>,
}Expand description
The Citum processor facade.
Takes a style, bibliography, and locale context, then delegates citation and bibliography work to the processor submodules.
Fields§
§style: StyleThe style definition.
bibliography: BibliographyThe bibliography (references keyed by ID).
locale: LocaleThe locale for terms and formatting.
default_config: ConfigDefault configuration.
hints: HashMap<String, ProcHints>Pre-calculated processing hints.
citation_numbers: RefCell<HashMap<String, usize>>Citation numbers assigned to references (for numeric styles).
cited_ids: RefCell<HashSet<String>>IDs of items that were cited in a visible way.
compound_sets: IndexMap<String, Vec<String>>Compound sets keyed by set ID.
compound_set_by_ref: HashMap<String, String>Reverse lookup for set membership by reference ID.
compound_member_index: HashMap<String, usize>Position within a set (0-based) for each reference ID.
compound_groups: RefCell<IndexMap<usize, Vec<String>>>Compound numeric groups: citation number → ordered ref IDs in the group.
dynamic_compound_set_by_ref: RefCell<HashMap<String, String>>Dynamic equivalent of compound_set_by_ref for cite-time groups.
Maps each dynamic group member (head and tails) to the head’s ref ID, which acts as the set identifier. Merged with static data at render time.
dynamic_compound_member_index: RefCell<HashMap<String, usize>>Dynamic equivalent of compound_member_index for cite-time groups.
Maps each dynamic group member to its 0-based position within the group. Merged with static data at render time.
dynamic_compound_sets: RefCell<IndexMap<String, Vec<String>>>Dynamic equivalent of compound_sets for cite-time groups.
Maps each dynamic group’s head ref ID to the ordered list of all members.
Merged with static compound_sets at render time so sub-label lookup works.
show_semantics: boolWhether to output semantic markup (HTML spans, Djot attributes).
Defaults to true; set to false to suppress class attributes (e.g. --no-semantics).
inject_ast_indices: boolWhether to annotate semantic HTML wrappers with source template indices.
abbreviation_map: Option<AbbreviationMap>Document-level abbreviation map for post-render substitution.
Implementations§
Source§impl Processor
impl Processor
Sourcepub fn render_grouped_bibliography_with_format<F>(&self) -> Stringwhere
F: OutputFormat<Output = String>,
pub fn render_grouped_bibliography_with_format<F>(&self) -> Stringwhere
F: OutputFormat<Output = String>,
Render the bibliography with grouping for uncited (nocite) items.
If style.bibliography.groups is defined, uses configurable grouping
with per-group sorting. Group selectors apply to individual references
before compound numeric rows are merged, so each rendered group only
includes the members that matched its selector. Otherwise, falls back to
hardcoded cited/uncited grouping for backward compatibility.
Sourcepub fn render_grouped_bibliography_with_format_and_annotations<F>(
&self,
annotations: Option<&HashMap<String, String>>,
annotation_style: Option<&AnnotationStyle>,
) -> Stringwhere
F: OutputFormat<Output = String>,
pub fn render_grouped_bibliography_with_format_and_annotations<F>(
&self,
annotations: Option<&HashMap<String, String>>,
annotation_style: Option<&AnnotationStyle>,
) -> Stringwhere
F: OutputFormat<Output = String>,
Render the bibliography with grouping and annotations.
Source§impl Processor
impl Processor
Sourcepub fn process_references(&self) -> ProcessedReferences
pub fn process_references(&self) -> ProcessedReferences
Process all bibliography references and render them.
Returns sorted and formatted bibliography entries. For numeric styles, citations must have been processed first to assign citation numbers.
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 and render 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 contributors_match(&self, prev: &Reference, current: &Reference) -> bool
pub fn contributors_match(&self, prev: &Reference, current: &Reference) -> bool
Check whether primary contributors match between two references.
Used for subsequent author substitution in bibliographies.
Replace the primary contributor with a substitution string.
Used for subsequent author substitution (e.g., “———”).
Sourcepub fn render_bibliography_with_format<F>(&self) -> Stringwhere
F: OutputFormat<Output = String>,
pub fn render_bibliography_with_format<F>(&self) -> Stringwhere
F: OutputFormat<Output = String>,
Render the bibliography to a string using a specific format.
Sourcepub fn render_bibliography_with_format_and_annotations<F>(
&self,
annotations: Option<&HashMap<String, String>>,
annotation_style: Option<&AnnotationStyle>,
) -> Stringwhere
F: OutputFormat<Output = String>,
pub fn render_bibliography_with_format_and_annotations<F>(
&self,
annotations: Option<&HashMap<String, String>>,
annotation_style: Option<&AnnotationStyle>,
) -> Stringwhere
F: OutputFormat<Output = String>,
Render the bibliography to a string with annotations.
Sourcepub fn render_selected_bibliography_with_format<F, I>(
&self,
item_ids: I,
) -> String
pub fn render_selected_bibliography_with_format<F, I>( &self, item_ids: I, ) -> String
Render a selected bibliography subset to a string using a specific format.
Sourcepub fn render_selected_bibliography_with_format_and_annotations<F, I>(
&self,
item_ids: I,
annotations: Option<&HashMap<String, String>>,
annotation_style: Option<&AnnotationStyle>,
) -> String
pub fn render_selected_bibliography_with_format_and_annotations<F, I>( &self, item_ids: I, annotations: Option<&HashMap<String, String>>, annotation_style: Option<&AnnotationStyle>, ) -> String
Render a selected bibliography subset to a string with annotations.
Orchestrates the choice between:
- Custom bibliography groups (selectors and headings).
- Automatic sort partitioning with sections (headings only).
- Standard flat rendering.
Sourcepub fn render_bibliography(&self) -> String
pub fn render_bibliography(&self) -> String
Render the entire bibliography to a formatted string.
Source§impl Processor
impl Processor
Sourcepub fn process_citation(
&self,
citation: &Citation,
) -> Result<String, ProcessorError>
pub fn process_citation( &self, citation: &Citation, ) -> Result<String, ProcessorError>
Render a single citation to plain text.
This is the primary entry point for citation processing. It handles:
- Looking up references in the bibliography.
- Annotating positions (ibid, subsequent, etc.).
- Resolving disambiguation (name expansion, year suffixes).
- Applying the style’s citation template.
Returns the formatted citation string or an error if processing fails.
§Errors
Returns an error when referenced items are missing or rendering fails.
Sourcepub fn process_citation_with_format<F>(
&self,
citation: &Citation,
) -> Result<String, ProcessorError>where
F: OutputFormat<Output = String>,
pub fn process_citation_with_format<F>(
&self,
citation: &Citation,
) -> Result<String, ProcessorError>where
F: OutputFormat<Output = String>,
Render a citation to a string using a specific output format.
This resolves the effective citation spec for the citation’s mode and position, renders the citation body, and applies input and style affixes.
§Errors
Returns an error when referenced items are missing or rendering fails.
Sourcepub fn process_citations(
&self,
citations: &[Citation],
) -> Result<Vec<String>, ProcessorError>
pub fn process_citations( &self, citations: &[Citation], ) -> Result<Vec<String>, ProcessorError>
Render multiple citations in document order.
For note-based styles, normalizes context and assigns citation positions.
§Errors
Returns an error when any citation in the sequence fails to render.
Sourcepub fn process_citations_with_format<F>(
&self,
citations: &[Citation],
) -> Result<Vec<String>, ProcessorError>where
F: OutputFormat<Output = String>,
pub fn process_citations_with_format<F>(
&self,
citations: &[Citation],
) -> Result<Vec<String>, ProcessorError>where
F: OutputFormat<Output = String>,
Render multiple citations with a custom output format.
§Errors
Returns an error when any citation in the sequence fails to render.
Source§impl Processor
impl Processor
Sourcepub fn normalize_note_context(&self, citations: &[Citation]) -> Vec<Citation>
pub fn normalize_note_context(&self, citations: &[Citation]) -> Vec<Citation>
Normalize citation note context for note styles.
Document/plugin layers should provide explicit note_number values.
When missing, this method assigns sequential note numbers in citation order.
Source§impl Processor
impl Processor
Sourcepub fn new(style: Style, bibliography: Bibliography) -> Self
pub fn new(style: Style, bibliography: Bibliography) -> Self
Create a new processor with default English locale (en-US).
Sourcepub fn try_with_compound_sets(
style: Style,
bibliography: Bibliography,
compound_sets: IndexMap<String, Vec<String>>,
) -> Result<Self, ProcessorError>
pub fn try_with_compound_sets( style: Style, bibliography: Bibliography, compound_sets: IndexMap<String, Vec<String>>, ) -> Result<Self, ProcessorError>
Create a new processor with explicit compound sets, returning an error for invalid sets.
§Errors
Returns an error when any compound set references unknown bibliography entries or reuses the same member more than once.
Sourcepub fn with_compound_sets(
style: Style,
bibliography: Bibliography,
compound_sets: IndexMap<String, Vec<String>>,
) -> Self
pub fn with_compound_sets( style: Style, bibliography: Bibliography, compound_sets: IndexMap<String, Vec<String>>, ) -> Self
Create a new processor with explicit compound sets.
If compound_sets is invalid, this constructor ignores the supplied sets
and falls back to a processor without compound sets.
Sourcepub fn with_locale(
style: Style,
bibliography: Bibliography,
locale: Locale,
) -> Self
pub fn with_locale( style: Style, bibliography: Bibliography, locale: Locale, ) -> Self
Create a new processor with a specified locale.
The locale determines term translations and locale-specific formatting behavior.
Sourcepub fn try_with_locale_and_compound_sets(
style: Style,
bibliography: Bibliography,
locale: Locale,
compound_sets: IndexMap<String, Vec<String>>,
) -> Result<Self, ProcessorError>
pub fn try_with_locale_and_compound_sets( style: Style, bibliography: Bibliography, locale: Locale, compound_sets: IndexMap<String, Vec<String>>, ) -> Result<Self, ProcessorError>
Create a new processor with explicit locale and compound sets, returning an error for invalid sets.
§Errors
Returns an error when any compound set references unknown bibliography entries or reuses the same member more than once.
Sourcepub fn with_locale_and_compound_sets(
style: Style,
bibliography: Bibliography,
locale: Locale,
compound_sets: IndexMap<String, Vec<String>>,
) -> Self
pub fn with_locale_and_compound_sets( style: Style, bibliography: Bibliography, locale: Locale, compound_sets: IndexMap<String, Vec<String>>, ) -> Self
Create a new processor with a specified locale and explicit compound sets.
The locale determines term translations and locale-specific formatting behavior.
If compound_sets is invalid, this constructor ignores the supplied sets
and falls back to a processor without compound sets.
Sourcepub fn with_style_locale(
style: Style,
bibliography: Bibliography,
locales_dir: &Path,
) -> Self
pub fn with_style_locale( style: Style, bibliography: Bibliography, locales_dir: &Path, ) -> Self
Create a new processor, loading the locale from disk.
Loads the locale specified in the style’s default_locale field from the given directory,
falling back to en-US if not found or not specified.
Sourcepub fn with_inject_ast_indices(self, inject_ast_indices: bool) -> Self
pub fn with_inject_ast_indices(self, inject_ast_indices: bool) -> Self
Return a copy of the processor that injects source template indices into semantic HTML.
Sourcepub fn set_inject_ast_indices(&mut self, inject_ast_indices: bool)
pub fn set_inject_ast_indices(&mut self, inject_ast_indices: bool)
Enable or disable source template index injection for semantic HTML output.
Sourcepub fn get_config(&self) -> &Config
pub fn get_config(&self) -> &Config
Return the global style configuration.
Sourcepub fn get_citation_config(&self) -> Cow<'_, Config>
pub fn get_citation_config(&self) -> Cow<'_, Config>
Return merged config for citation rendering.
Combines global style options with citation-specific overrides.
Sourcepub fn get_bibliography_config(&self) -> Cow<'_, Config>
pub fn get_bibliography_config(&self) -> Cow<'_, Config>
Return merged shared config for bibliography rendering.
Combines global shared style options with bibliography-local shared overrides.
Sourcepub fn get_bibliography_options(&self) -> Cow<'_, BibliographyConfig>
pub fn get_bibliography_options(&self) -> Cow<'_, BibliographyConfig>
Return effective bibliography-only configuration.
Sourcepub fn sort_references<'a>(
&self,
references: Vec<&'a Reference>,
) -> Vec<&'a Reference>
pub fn sort_references<'a>( &self, references: Vec<&'a Reference>, ) -> Vec<&'a Reference>
Sort references according to the style’s bibliography sort specification.
Uses style-specified sort keys (author, title, issued, etc.) and sort order.
Sourcepub fn sort_citation_items(
&self,
items: Vec<CitationItem>,
spec: &CitationSpec,
) -> Vec<CitationItem>
pub fn sort_citation_items( &self, items: Vec<CitationItem>, spec: &CitationSpec, ) -> Vec<CitationItem>
Sort citation items according to the style’s citation sort specification.
Sourcepub fn calculate_hints(&self) -> HashMap<String, ProcHints>
pub fn calculate_hints(&self) -> HashMap<String, ProcHints>
Calculate disambiguation hints needed for the style.
Analyzes the bibliography to determine which items need disambiguation (year suffixes, etc.) and calculates hints for efficient rendering.
Source§impl Processor
impl Processor
Sourcepub fn process_document<P, F>(
&self,
content: &str,
parser: &P,
format: DocumentFormat,
) -> String
pub fn process_document<P, F>( &self, content: &str, parser: &P, format: DocumentFormat, ) -> String
Process citations in a document and append a bibliography.
This is the primary document-level entry point. It:
- Parses the source document using the provided adapter.
- Resolves frontmatter overrides (integral-name policy, bibliography options).
- Chooses a bibliography orchestration path based on frontmatter and document blocks.