summaryrefslogtreecommitdiffstats
path: root/examples/markdown
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-08-22 02:24:06 +0200
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-08-22 02:24:06 +0200
commit4c883f12b4761c7e0b273d9a2380552336f61d96 (patch)
treee2ef505aaa87b84bad010a633a9a96891b50df7d /examples/markdown
parent55764b923e69afa8a92b4a6cbd34ee9ddbf8a03d (diff)
downloadiced-4c883f12b4761c7e0b273d9a2380552336f61d96.tar.gz
iced-4c883f12b4761c7e0b273d9a2380552336f61d96.tar.bz2
iced-4c883f12b4761c7e0b273d9a2380552336f61d96.zip
Make `RichText` generic over data structure
... and decouple `markdown::parse` from theming
Diffstat (limited to 'examples/markdown')
-rw-r--r--examples/markdown/src/main.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/examples/markdown/src/main.rs b/examples/markdown/src/main.rs
index eb51f985..5605478f 100644
--- a/examples/markdown/src/main.rs
+++ b/examples/markdown/src/main.rs
@@ -29,8 +29,7 @@ impl Markdown {
(
Self {
content: text_editor::Content::with_text(INITIAL_CONTENT),
- items: markdown::parse(INITIAL_CONTENT, theme.palette())
- .collect(),
+ items: markdown::parse(INITIAL_CONTENT).collect(),
theme,
},
widget::focus_next(),
@@ -45,11 +44,8 @@ impl Markdown {
self.content.perform(action);
if is_edit {
- self.items = markdown::parse(
- &self.content.text(),
- self.theme.palette(),
- )
- .collect();
+ self.items =
+ markdown::parse(&self.content.text()).collect();
}
}
Message::LinkClicked(link) => {
@@ -67,8 +63,12 @@ impl Markdown {
.font(Font::MONOSPACE)
.highlight("markdown", highlighter::Theme::Base16Ocean);
- let preview = markdown(&self.items, markdown::Settings::default())
- .map(Message::LinkClicked);
+ let preview = markdown(
+ &self.items,
+ markdown::Settings::default(),
+ markdown::Style::from_palette(self.theme.palette()),
+ )
+ .map(Message::LinkClicked);
row![editor, scrollable(preview).spacing(10).height(Fill)]
.spacing(10)