diff options
author | 2025-02-04 20:18:49 +0100 | |
---|---|---|
committer | 2025-02-04 20:19:25 +0100 | |
commit | 387abafa3abda3ba68eb7a2e4ce4240ad3bdda53 (patch) | |
tree | 42e3334d4bba44620679d8cbd1ba252eec287139 /examples | |
parent | a6e64eac6f2a4451cdc100e4019ab76e1ce68064 (diff) | |
download | iced-387abafa3abda3ba68eb7a2e4ce4240ad3bdda53.tar.gz iced-387abafa3abda3ba68eb7a2e4ce4240ad3bdda53.tar.bz2 iced-387abafa3abda3ba68eb7a2e4ce4240ad3bdda53.zip |
Add `alt` and `title` to `markdown` images
Diffstat (limited to 'examples')
-rw-r--r-- | examples/markdown/src/main.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/examples/markdown/src/main.rs b/examples/markdown/src/main.rs index 2fb25376..84c20b7e 100644 --- a/examples/markdown/src/main.rs +++ b/examples/markdown/src/main.rs @@ -195,7 +195,7 @@ impl Markdown { let preview = markdown::view_with( self.content.items(), &self.theme, - &MarkdownViewer { + &CustomViewer { images: &self.images, now: self.now, }, @@ -251,12 +251,12 @@ impl Markdown { } } -struct MarkdownViewer<'a> { +struct CustomViewer<'a> { images: &'a HashMap<markdown::Url, Image>, now: Instant, } -impl<'a> markdown::Viewer<'a, Message> for MarkdownViewer<'a> { +impl<'a> markdown::Viewer<'a, Message> for CustomViewer<'a> { fn on_link_clicked(url: markdown::Url) -> Message { Message::LinkClicked(url) } @@ -264,8 +264,9 @@ impl<'a> markdown::Viewer<'a, Message> for MarkdownViewer<'a> { fn image( &self, _settings: markdown::Settings, - _title: &markdown::Text, url: &'a markdown::Url, + _title: &'a str, + _alt: &markdown::Text, ) -> Element<'a, Message> { if let Some(Image::Ready { handle, fade_in }) = self.images.get(url) { center_x( |