pub struct CommonMarkCache {
pub navigation: Navigation,
/* private fields */
}Expand description
A cache used for storing content such as images.
Fields§
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>, ) -> Result<(), ParseSyntaxError>
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 scroll_to_id_target(&self) -> Option<&str>
pub fn scroll_to_id_target(&self) -> Option<&str>
Get the desired fragment. This is the id which will be scrolled to if it is found in the markdown.
Sourcepub fn scroll_to_id_target_mut(&mut self) -> &mut Option<String>
pub fn scroll_to_id_target_mut(&mut self) -> &mut Option<String>
Get mutable access to the desired fragment. Setting this will cause the viewer to scroll to the heading with this id if it exists. Setting it to None will prevent scrolling.
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 AsId) -> bool
pub fn clear_scrollable_with_id(&mut self, source_id: impl AsId) -> 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 egui_commonmark to check for link hooks while rendering. Normally when hovering over a link, egui_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
Trait Implementations§
Source§impl Debug for CommonMarkCache
impl Debug for CommonMarkCache
Source§impl Default for CommonMarkCache
impl Default for CommonMarkCache
Source§fn default() -> CommonMarkCache
fn default() -> CommonMarkCache
Auto Trait Implementations§
impl !Freeze for CommonMarkCache
impl !Sync for CommonMarkCache
impl RefUnwindSafe for CommonMarkCache
impl Send for CommonMarkCache
impl Unpin for CommonMarkCache
impl UnsafeUnpin for CommonMarkCache
impl UnwindSafe for CommonMarkCache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more