pub struct CommonMarkCache { /* private fields */ }Expand description
A cache used for storing content such as images.
Implementations§
Source§impl CommonMarkCache
impl CommonMarkCache
pub fn add_syntax_from_folder(&mut self, path: &str)
pub fn add_syntax_from_str(&mut self, s: &str, fallback_name: Option<&str>)
Sourcepub fn add_syntax_themes_from_folder(
&mut self,
path: impl AsRef<Path>,
) -> Result<(), LoadingError>
pub fn add_syntax_themes_from_folder( &mut self, path: impl AsRef<Path>, ) -> Result<(), LoadingError>
Add more color themes for code blocks(.tmTheme files). Set the color theme with
syntax_theme_dark and
syntax_theme_light
Sourcepub fn add_syntax_theme_from_bytes(
&mut self,
name: impl Into<String>,
bytes: &[u8],
) -> Result<(), LoadingError>
pub fn add_syntax_theme_from_bytes( &mut self, name: impl Into<String>, bytes: &[u8], ) -> Result<(), LoadingError>
Add color theme for code blocks(.tmTheme files). Set the color theme with
syntax_theme_dark and
syntax_theme_light
Sourcepub fn clear_scrollable(&mut self)
pub fn clear_scrollable(&mut self)
Clear the cache for all scrollable elements
Sourcepub fn clear_scrollable_with_id(&mut self, source_id: impl Hash) -> bool
pub fn clear_scrollable_with_id(&mut self, source_id: impl Hash) -> bool
Clear the cache for a specific scrollable viewer. Returns false if the id was not in the cache.
Sourcepub fn add_link_hook<S>(&mut self, name: S)
pub fn add_link_hook<S>(&mut self, name: S)
If the user clicks on a link in the markdown render that has name as a link. The hook
specified with this method will be set to true. It’s status can be acquired
with get_link_hook. Be aware that all hook state is reset once
[CommonMarkViewer::show] gets called
§Why use link hooks
egui provides a method for checking links afterwards so why use this instead?
ctx.output_mut(|o| for command in &o.commands {
matches!(command, egui::OutputCommand::OpenUrl(_));
});The main difference is that link hooks allows gorbie_commonmark to check for link hooks while rendering. Normally when hovering over a link, gorbie_commonmark will display the full url. With link hooks this feature is disabled, but to do that all hooks must be known.
Sourcepub fn remove_link_hook(&mut self, name: &str) -> Option<bool>
pub fn remove_link_hook(&mut self, name: &str) -> Option<bool>
Returns None if the link hook could not be found. Returns the last known status of the hook otherwise.
Sourcepub fn get_link_hook(&self, name: &str) -> Option<bool>
pub fn get_link_hook(&self, name: &str) -> Option<bool>
Get status of link. Returns true if it was clicked
Sourcepub fn link_hooks_clear(&mut self)
pub fn link_hooks_clear(&mut self)
Remove all link hooks
Sourcepub fn link_hooks(&self) -> &HashMap<String, bool>
pub fn link_hooks(&self) -> &HashMap<String, bool>
All link hooks
Sourcepub fn link_hooks_mut(&mut self) -> &mut HashMap<String, bool>
pub fn link_hooks_mut(&mut self) -> &mut HashMap<String, bool>
Raw access to link hooks