diff options
-rw-r--r-- | examples/markdown/src/main.rs | 9 | ||||
-rw-r--r-- | widget/src/markdown.rs | 14 |
2 files changed, 10 insertions, 13 deletions
diff --git a/examples/markdown/src/main.rs b/examples/markdown/src/main.rs index db40d0b9..efe5b324 100644 --- a/examples/markdown/src/main.rs +++ b/examples/markdown/src/main.rs @@ -28,11 +28,8 @@ impl Markdown { ( Self { content: text_editor::Content::with_text(INITIAL_CONTENT), - items: markdown::parse( - INITIAL_CONTENT, - theme.extended_palette(), - ) - .collect(), + items: markdown::parse(INITIAL_CONTENT, &theme.palette()) + .collect(), theme, }, widget::focus_next(), @@ -49,7 +46,7 @@ impl Markdown { if is_edit { self.items = markdown::parse( &self.content.text(), - self.theme.extended_palette(), + &self.theme.palette(), ) .collect(); } diff --git a/widget/src/markdown.rs b/widget/src/markdown.rs index 6cd8535e..362aba67 100644 --- a/widget/src/markdown.rs +++ b/widget/src/markdown.rs @@ -8,9 +8,8 @@ use crate::core::border; use crate::core::font::{self, Font}; use crate::core::padding; use crate::core::text::Background; -use crate::core::theme::palette; -use crate::core::theme::Theme; -use crate::core::{self, Element, Length, Pixels}; +use crate::core::theme::{self, Theme}; +use crate::core::{self, color, Color, Element, Length, Pixels}; use crate::{column, container, rich_text, row, scrollable, span, text}; pub use pulldown_cmark::HeadingLevel; @@ -39,7 +38,7 @@ pub enum Item { /// Parse the given Markdown content. pub fn parse<'a>( markdown: &'a str, - palette: &'a palette::Extended, + palette: &'a theme::Palette, ) -> impl Iterator<Item = Item> + 'a { struct List { start: Option<u64>, @@ -250,7 +249,7 @@ pub fn parse<'a>( }; let span = if let Some(link) = link.as_ref() { - span.color(palette.primary.base.color).link(link.clone()) + span.color(palette.primary).link(link.clone()) } else { span }; @@ -262,13 +261,14 @@ pub fn parse<'a>( pulldown_cmark::Event::Code(code) if !metadata && !table => { let span = span(code.into_string()) .font(Font::MONOSPACE) + .color(Color::WHITE) .background(Background { - color: palette.background.weak.color, + color: color!(0x111111), border: border::rounded(2), }); let span = if let Some(link) = link.as_ref() { - span.color(palette.primary.base.color).link(link.clone()) + span.color(palette.primary).link(link.clone()) } else { span }; |