pub trait OutputFormat: Default + Clone {
type Output;
Show 31 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 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 quote_marks(&self, depth: usize) -> (&'static str, &'static str) { ... }
fn quote_with_depth(
&self,
content: Self::Output,
depth: usize,
) -> Self::Output { ... }
fn quote(&self, content: Self::Output) -> Self::Output { ... }
fn paragraph(&self, content: Self::Output) -> Self::Output { ... }
fn block_quote(&self, content: Self::Output) -> Self::Output { ... }
fn bullet_list(&self, items: Vec<Self::Output>) -> Self::Output { ... }
fn ordered_list(&self, items: Vec<Self::Output>) -> Self::Output { ... }
fn list_item(&self, content: Self::Output) -> Self::Output { ... }
fn heading(&self, _level: u8, content: Self::Output) -> Self::Output { ... }
fn code_block(
&self,
_lang: Option<&str>,
content: Self::Output,
) -> Self::Output { ... }
fn inline_code(&self, content: Self::Output) -> Self::Output { ... }
fn strikeout(&self, content: Self::Output) -> Self::Output { ... }
fn hard_break(&self) -> Self::Output { ... }
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§
Required Methods§
Sourcefn text(&self, s: &str) -> Self::Output
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.
Sourcefn join(&self, items: Vec<Self::Output>, delimiter: &str) -> Self::Output
fn join(&self, items: Vec<Self::Output>, delimiter: &str) -> Self::Output
Join multiple outputs into a single output using a delimiter.
Sourcefn finish(&self, output: Self::Output) -> String
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).
Sourcefn emph(&self, content: Self::Output) -> Self::Output
fn emph(&self, content: Self::Output) -> Self::Output
Render content with emphasis (typically italics).
Sourcefn strong(&self, content: Self::Output) -> Self::Output
fn strong(&self, content: Self::Output) -> Self::Output
Render content with strong emphasis (typically bold).
Sourcefn small_caps(&self, content: Self::Output) -> Self::Output
fn small_caps(&self, content: Self::Output) -> Self::Output
Render content in small capitals.
Sourcefn superscript(&self, content: Self::Output) -> Self::Output
fn superscript(&self, content: Self::Output) -> Self::Output
Render content as superscript text.
Sourcefn affix(
&self,
prefix: &str,
content: Self::Output,
suffix: &str,
) -> Self::Output
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.
Sourcefn inner_affix(
&self,
prefix: &str,
content: Self::Output,
suffix: &str,
) -> Self::Output
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.
Sourcefn wrap_punctuation(
&self,
wrap: &WrapPunctuation,
content: Self::Output,
) -> Self::Output
fn wrap_punctuation( &self, wrap: &WrapPunctuation, content: Self::Output, ) -> Self::Output
Wrap the content in specific punctuation (parentheses, brackets, or quotes).
Sourcefn semantic(&self, class: &str, content: Self::Output) -> Self::Output
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”.
Sourcefn annotation(&self, content: Self::Output) -> Self::Output
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.
Provided Methods§
Sourcefn quote_marks(&self, depth: usize) -> (&'static str, &'static str)
fn quote_marks(&self, depth: usize) -> (&'static str, &'static str)
Return the opening and closing quote delimiters for a nesting depth.
Depth 0 is an outer quote pair, depth 1 is the first inner quote pair, and deeper levels alternate between those two pairs.
Sourcefn quote_with_depth(&self, content: Self::Output, depth: usize) -> Self::Output
fn quote_with_depth(&self, content: Self::Output, depth: usize) -> Self::Output
Render content enclosed in quotation marks at a specific nesting depth.
Sourcefn quote(&self, content: Self::Output) -> Self::Output
fn quote(&self, content: Self::Output) -> Self::Output
Render content enclosed in outer quotation marks.
Sourcefn block_quote(&self, content: Self::Output) -> Self::Output
fn block_quote(&self, content: Self::Output) -> Self::Output
Render a block quotation.
Sourcefn bullet_list(&self, items: Vec<Self::Output>) -> Self::Output
fn bullet_list(&self, items: Vec<Self::Output>) -> Self::Output
Render an unordered (bullet) list from pre-rendered item strings.
Sourcefn ordered_list(&self, items: Vec<Self::Output>) -> Self::Output
fn ordered_list(&self, items: Vec<Self::Output>) -> Self::Output
Render an ordered (numbered) list from pre-rendered item strings.
Sourcefn heading(&self, _level: u8, content: Self::Output) -> Self::Output
fn heading(&self, _level: u8, content: Self::Output) -> Self::Output
Render a heading at the given level (1 = top-level).
Sourcefn code_block(&self, _lang: Option<&str>, content: Self::Output) -> Self::Output
fn code_block(&self, _lang: Option<&str>, content: Self::Output) -> Self::Output
Render a fenced or indented code block with an optional language hint.
content is the raw (unescaped) code text.
Sourcefn inline_code(&self, content: Self::Output) -> Self::Output
fn inline_code(&self, content: Self::Output) -> Self::Output
Render inline code.
Sourcefn hard_break(&self) -> Self::Output
fn hard_break(&self) -> Self::Output
Render a hard line break.
Sourcefn semantic_with_attributes(
&self,
class: &str,
content: Self::Output,
_attributes: &[SemanticAttribute],
) -> Self::Output
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.
Sourcefn citation(&self, _ids: Vec<String>, content: Self::Output) -> Self::Output
fn citation(&self, _ids: Vec<String>, content: Self::Output) -> Self::Output
Render a full citation container with one or more reference IDs.
Sourcefn format_id(&self, id: &str) -> String
fn format_id(&self, id: &str) -> String
Format a reference ID for use as a target or link (e.g. adding a prefix).
Sourcefn bibliography(&self, entries: Vec<Self::Output>) -> Self::Output
fn bibliography(&self, entries: Vec<Self::Output>) -> Self::Output
Render a full bibliography container.
The default implementation joins the entries with double newlines.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".