Skip to main content

CitationParser

Trait CitationParser 

Source
pub trait CitationParser {
    // Required method
    fn parse_document(&self, content: &str, locale: &Locale) -> ParsedDocument;

    // Provided methods
    fn finalize_html_output(&self, rendered: &str) -> String { ... }
    fn parse_citations(
        &self,
        content: &str,
        locale: &Locale,
    ) -> Vec<(usize, usize, Citation)> { ... }
}
Expand description

A trait for document parsers that can identify citations.

Each implementation is a format-specific adapter (Djot, Markdown, etc.). Adapters are responsible for source-syntax citation parsing, note discovery, frontmatter extraction, bibliography block detection, and HTML finalization. The shared pipeline consumes the resulting ParsedDocument without inspecting format-specific internals.

Required Methods§

Source

fn parse_document(&self, content: &str, locale: &Locale) -> ParsedDocument

Parse the document into citation placements and note metadata.

Provided Methods§

Source

fn finalize_html_output(&self, rendered: &str) -> String

Finalize rendered document markup as HTML.

Called after citation strings have been spliced back into the source markup and the result must be converted to HTML. The default implementation is a pass-through: it returns the markup unchanged. Format-specific adapters that require a markup-to-HTML conversion step (e.g. Djot via jotdown) must override this method.

Source

fn parse_citations( &self, content: &str, locale: &Locale, ) -> Vec<(usize, usize, Citation)>

Find and extract citations from a document string.

Returns a list of (start_index, end_index, citation_model) tuples.

Implementors§