Skip to main content

OutputFormat

Trait OutputFormat 

Source
pub trait OutputFormat: Default + Clone {
    type Output;

Show 19 methods // Required methods fn text(&self, s: &str) -> Self::Output; fn join(&self, items: Vec<Self::Output>, delimiter: &str) -> Self::Output; fn finish(&self, output: Self::Output) -> String; fn emph(&self, content: Self::Output) -> Self::Output; fn strong(&self, content: Self::Output) -> Self::Output; fn small_caps(&self, content: Self::Output) -> Self::Output; fn superscript(&self, content: Self::Output) -> Self::Output; fn quote(&self, content: Self::Output) -> Self::Output; fn affix( &self, prefix: &str, content: Self::Output, suffix: &str, ) -> Self::Output; fn inner_affix( &self, prefix: &str, content: Self::Output, suffix: &str, ) -> Self::Output; fn wrap_punctuation( &self, wrap: &WrapPunctuation, content: Self::Output, ) -> Self::Output; fn semantic(&self, class: &str, content: Self::Output) -> Self::Output; fn annotation(&self, content: Self::Output) -> Self::Output; fn link(&self, url: &str, content: Self::Output) -> Self::Output; // Provided methods fn semantic_with_attributes( &self, class: &str, content: Self::Output, _attributes: &[SemanticAttribute], ) -> Self::Output { ... } fn citation(&self, _ids: Vec<String>, content: Self::Output) -> Self::Output { ... } fn format_id(&self, id: &str) -> String { ... } fn bibliography(&self, entries: Vec<Self::Output>) -> Self::Output { ... } fn entry( &self, _id: &str, content: Self::Output, _url: Option<&str>, _metadata: &ProcEntryMetadata, ) -> Self::Output { ... }
}
Expand description

Trait for defining how to render template components into a specific format.

Implementations of this trait define how various formatting instructions (emphasis, quotes, links, etc.) are translated into specific markup or text.

Required Associated Types§

Source

type Output

The type used for intermediate rendered content.

For simple text formats, this is usually String. More complex formats might use an AST or a specialized builder type.

Required Methods§

Source

fn text(&self, s: &str) -> Self::Output

Convert a raw string into the format’s output type.

The implementation should handle any necessary character escaping required by the target format.

Source

fn join(&self, items: Vec<Self::Output>, delimiter: &str) -> Self::Output

Join multiple outputs into a single output using a delimiter.

Source

fn finish(&self, output: Self::Output) -> String

Convert the intermediate output into the final result string.

This is called exactly once at the end of the rendering process for a top-level component (citation or bibliography entry).

Source

fn emph(&self, content: Self::Output) -> Self::Output

Render content with emphasis (typically italics).

Source

fn strong(&self, content: Self::Output) -> Self::Output

Render content with strong emphasis (typically bold).

Source

fn small_caps(&self, content: Self::Output) -> Self::Output

Render content in small capitals.

Source

fn superscript(&self, content: Self::Output) -> Self::Output

Render content as superscript text.

Source

fn quote(&self, content: Self::Output) -> Self::Output

Render content enclosed in quotation marks.

Source

fn affix( &self, prefix: &str, content: Self::Output, suffix: &str, ) -> Self::Output

Apply outer prefix and suffix strings to the content.

These are typically the “prefix” and “suffix” fields from the Citum style.

Source

fn inner_affix( &self, prefix: &str, content: Self::Output, suffix: &str, ) -> Self::Output

Apply inner prefix and suffix strings to the content.

These are applied inside any wrapping punctuation.

Source

fn wrap_punctuation( &self, wrap: &WrapPunctuation, content: Self::Output, ) -> Self::Output

Wrap the content in specific punctuation (parentheses, brackets, or quotes).

Source

fn semantic(&self, class: &str, content: Self::Output) -> Self::Output

Apply a semantic identifier (class) to the content.

This is used for machine readability or fine-grained CSS styling. Examples include “citum-title”, “citum-author”, “citum-doi”.

Source

fn annotation(&self, content: Self::Output) -> Self::Output

Render an annotation block.

This is typically called at the end of a bibliography entry to render reader-supplied notes.

Hyperlink the content to a URL.

Provided Methods§

Source

fn semantic_with_attributes( &self, class: &str, content: Self::Output, _attributes: &[SemanticAttribute], ) -> Self::Output

Apply a semantic identifier plus optional attributes to the content.

Formats that do not support extra attributes can ignore them and reuse Self::semantic.

Source

fn citation(&self, _ids: Vec<String>, content: Self::Output) -> Self::Output

Render a full citation container with one or more reference IDs.

Source

fn format_id(&self, id: &str) -> String

Format a reference ID for use as a target or link (e.g. adding a prefix).

Source

fn bibliography(&self, entries: Vec<Self::Output>) -> Self::Output

Render a full bibliography container.

The default implementation joins the entries with double newlines.

Source

fn entry( &self, _id: &str, content: Self::Output, _url: Option<&str>, _metadata: &ProcEntryMetadata, ) -> Self::Output

Render a single bibliography entry with its unique identifier and optional link.

The default implementation just returns the content.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§