pub trait DocumentFormat: Send + Sync {
// Required methods
fn id(&self) -> &str;
fn name(&self) -> &str;
// Provided methods
fn aliases(&self) -> Vec<String> { ... }
fn extensions(&self) -> Vec<String> { ... }
fn match_name(&self, file_name: &str) -> NameMatch { ... }
fn sniff(&self, _text: &str) -> f32 { ... }
fn features(&self) -> Vec<String> { ... }
fn parse(&self, _source: &str) -> Option<Parsed> { ... }
fn render(&self, source: &str, options: &RenderOptions) -> Rendered { ... }
}Expand description
A documentation format: how to recognise it and how to draw it.
Required Methods§
Provided Methods§
Sourcefn extensions(&self) -> Vec<String>
fn extensions(&self) -> Vec<String>
The file extensions it claims, lowercase, without the dot.
Sourcefn match_name(&self, file_name: &str) -> NameMatch
fn match_name(&self, file_name: &str) -> NameMatch
How file_name (a base name) relates to this format. By default a
name whose extension is one of extensions is
NameMatch::Yes.
Sourcefn features(&self) -> Vec<String>
fn features(&self) -> Vec<String>
What the format supports ("tables", "admonitions", …), for
listings and for callers that want to know before rendering.
Sourcefn parse(&self, _source: &str) -> Option<Parsed>
fn parse(&self, _source: &str) -> Option<Parsed>
Parse source into the shared model, for formats built on it.
Sourcefn render(&self, source: &str, options: &RenderOptions) -> Rendered
fn render(&self, source: &str, options: &RenderOptions) -> Rendered
Render source. The default draws parse’s document
with DocumentView, or the source as plain text when the format
does not parse into the model.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl DocumentFormat for AsciiDocFormat
impl DocumentFormat for ManFormat
impl DocumentFormat for MarkdownFormat
Available on crate feature
markdown only.