pub trait InlineSubstitutionRenderer: Debug {
// Required methods
fn render_special_character(
&self,
type_: SpecialCharacter,
dest: &mut String,
);
fn render_quoted_substitition(
&self,
type_: QuoteType,
scope: QuoteScope,
attrlist: Option<Attrlist<'_>>,
id: Option<String>,
body: &str,
dest: &mut String,
);
fn render_character_replacement(
&self,
type_: CharacterReplacementType,
dest: &mut String,
);
fn render_line_break(&self, dest: &mut String);
fn render_image(&self, params: &ImageRenderParams<'_>, dest: &mut String);
fn image_uri(
&self,
target_image_path: &str,
parser: &Parser,
asset_dir_key: Option<&str>,
) -> String;
fn render_icon(&self, params: &IconRenderParams<'_>, dest: &mut String);
fn render_link(&self, params: &LinkRenderParams<'_>, dest: &mut String);
fn render_anchor(
&self,
id: &str,
reftext: Option<String>,
dest: &mut String,
);
// Provided method
fn icon_uri(
&self,
name: &str,
_attrlist: &Attrlist<'_>,
parser: &Parser,
) -> String { ... }
}Expand description
An implementation of InlineSubstitutionRenderer is used when converting
the basic raw text of a simple block to the format which will ultimately be
presented in the final converted output.
An implementation is provided for HTML output; alternative implementations (not provided in this crate) could support other output formats.
Required Methods§
Sourcefn render_special_character(&self, type_: SpecialCharacter, dest: &mut String)
fn render_special_character(&self, type_: SpecialCharacter, dest: &mut String)
Renders the substitution for a special character.
The renderer should write the appropriate rendering to dest.
Sourcefn render_quoted_substitition(
&self,
type_: QuoteType,
scope: QuoteScope,
attrlist: Option<Attrlist<'_>>,
id: Option<String>,
body: &str,
dest: &mut String,
)
fn render_quoted_substitition( &self, type_: QuoteType, scope: QuoteScope, attrlist: Option<Attrlist<'_>>, id: Option<String>, body: &str, dest: &mut String, )
Renders the content of a quote substitution.
The renderer should write the appropriate rendering to dest.
Sourcefn render_character_replacement(
&self,
type_: CharacterReplacementType,
dest: &mut String,
)
fn render_character_replacement( &self, type_: CharacterReplacementType, dest: &mut String, )
Renders the content of a character replacement.
The renderer should write the appropriate rendering to dest.
Sourcefn render_line_break(&self, dest: &mut String)
fn render_line_break(&self, dest: &mut String)
Renders a line break.
The renderer should write an appropriate rendering of line break to
dest.
This is used in the implementation of post-replacement substitutions.
Sourcefn render_image(&self, params: &ImageRenderParams<'_>, dest: &mut String)
fn render_image(&self, params: &ImageRenderParams<'_>, dest: &mut String)
Renders an image.
The renderer should write an appropriate rendering of the specified
image to dest.
Sourcefn image_uri(
&self,
target_image_path: &str,
parser: &Parser,
asset_dir_key: Option<&str>,
) -> String
fn image_uri( &self, target_image_path: &str, parser: &Parser, asset_dir_key: Option<&str>, ) -> String
Construct a URI reference or data URI to the target image.
If the target_image_path is a URI reference, then leave it untouched.
The target_image_path is resolved relative to the directory retrieved
from the specified document-scoped attribute key, if provided.
NOT YET IMPLEMENTED:
If the data-uri attribute is set on the document, and the safe mode
level is less than SafeMode::SECURE, the image will be safely
converted to a data URI by reading it from the same directory. If
neither of these conditions are satisfied, a relative path (i.e., URL)
will be returned.
§Parameters
target_image_path: path to the target imageparser: Current document parser stateasset_dir_key: If provided, the attribute key used to look up the directory where the image is located. If not provided,imagesdiris used.
§Return
Returns a string reference or data URI for the target image that can be safely used in an image tag.
Sourcefn render_icon(&self, params: &IconRenderParams<'_>, dest: &mut String)
fn render_icon(&self, params: &IconRenderParams<'_>, dest: &mut String)
Renders an icon.
The renderer should write an appropriate rendering of the specified
icon to dest.
Sourcefn render_link(&self, params: &LinkRenderParams<'_>, dest: &mut String)
fn render_link(&self, params: &LinkRenderParams<'_>, dest: &mut String)
Renders a link.
The renderer should write an appropriate rendering of the specified
link, to dest.
Provided Methods§
Sourcefn icon_uri(
&self,
name: &str,
_attrlist: &Attrlist<'_>,
parser: &Parser,
) -> String
fn icon_uri( &self, name: &str, _attrlist: &Attrlist<'_>, parser: &Parser, ) -> String
Construct a reference or data URI to an icon image for the specified icon name.
If the icon attribute is set on this block, the name is ignored and
the value of this attribute is used as the target image path. Otherwise,
construct a target image path by concatenating the value of the
iconsdir attribute, the icon name, and the value of the icontype
attribute (defaulting to png).
The target image path is then passed through the image_uri() method.
If the data-uri attribute is set on the document, the image will be
safely converted to a data URI.
The return value of this method can be safely used in an image tag.